DispatchQueue.global(qos: .userInteractive).async { [weak self] in
guard let self = self else { return }
guard let inputItem = self.extensionContext? NsextensionItem else {return}
Guard Var Attachments = inputitem.attachments else {return} < /p>
Код: Выделить всё
// Remove unwanted MapKit item types
attachments.removeAll {
$0.hasItemConformingToTypeIdentifier("com.apple.mapkit.map-item")
}
let maxCount = attachments.count
debugPrint("handleShareObject:: Shared contents:", attachments)
for attachment in attachments {
if attachment.hasItemConformingToTypeIdentifier(self.imageContentType) {
self.handleShareObject(attachment: attachment, type: .image, maxCount: maxCount)
} else if attachment.hasItemConformingToTypeIdentifier(self.textContentType) {
self.handleShareObject(attachment: attachment, type: .text, maxCount: maxCount)
} else if attachment.hasItemConformingToTypeIdentifier(self.videoContentType) {
self.handleShareObject(attachment: attachment, type: .video, maxCount: maxCount)
} else if attachment.hasItemConformingToTypeIdentifier(self.fileAudioType) {
self.handleShareObject(attachment: attachment, type: .audio, maxCount: maxCount)
} else if attachment.hasItemConformingToTypeIdentifier(self.fileURLType) {
self.handleShareObject(attachment: attachment, type: .file, maxCount: maxCount)
} else if attachment.hasItemConformingToTypeIdentifier(self.urlContentType) {
self.handleShareObject(attachment: attachment, type: .url, maxCount: maxCount)
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... icates-sam