I'm having trouble getting a sharing extension to work. I have the following in my sharing controller.
let item: NSExtensionItem = self.extensionContext.inputItems[0] as NSExtensionItem
let itemProvider: NSItemProvider = item.attachments[0] as NSItemProvider
var URL: NSString
if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeURL) {
itemProvider.loadItemForTypeIdentifier(kUTTypeURL, options: nil, completionHandler: {(url: NSURL, error: NSError) in
URL = url.absoluteString
})
}
self.extensionContext.completeRequestReturningItems(nil, completionHandler: nil)
This gives me the error Use of unresolved identifier 'kUTTypeURL'
on the line if itemProvider.hasItemConformingToTypeIdentifier(kUTTypeURL) {
.
It seems to be defined as a constant in Swift, but I can't seem to access it. Is it part of an enum? Do I have to import something to get access to it?
Thanks for your help.
Just so this question has an answer:
Add import MobileCoreServices
to your source file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With