基本上,我想从其他应用程序(例如保管箱)中检索文件(例如pdf),以便以后存储和修改。
我为该任务编写了共享扩展名,并且可以遍历NSExtensionItem并可以捕获我的文件-但我不知道它们的原始文件名。
我注意到其他应用程序都获得了文件名-但是在iOS中使用“打开方式”功能对其进行了调用。
那么,如何在共享扩展名中获取文件名?
提前致谢。
您在收到的URL中将文件名作为lastPathComponent:
itemProvider!.first!.loadItemForTypeIdentifier(kUTTypeImage as String, options: nil, completionHandler: {
(provider, error) in
let url = provider as! NSURL
println(url)
let data = NSData(contentsOfURL: url)
let name = url.lastPathComponent!
...
// Inform the host that we're done, so it un-blocks its UI. Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context.
self.extensionContext!.completeRequestReturningItems([], completionHandler: nil)
})
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句