保存文件宿主应用程序
问题描述:
我工作的一个应用程序扩展,我想允许用户与主机应用程序共享各种文件。保存文件宿主应用程序
实施例:挑选照片,通过应用选择份额,照片保存到共享文件夹&然后可用时用户下次打开主机应用程序。
我的主机应用程序已准备好从共享文件夹中读取数据,而扩展名仅用图像设置,但我坚持的是检索文件数据(blob或路径我不确定?),然后将其写入共享文件夹。
下面是扩展的相关章节:
override func didSelectPost() {
let content = extensionContext!.inputItems[0] as NSExtensionItem
for attachment in content.attachments as [NSItemProvider] {
// Image attachment
if attachment.hasItemConformingToTypeIdentifier(kUTTypeImage as String) {
// save this to file in shared folder for host app to retrieve...
}
}
self.extensionContext!.completeRequestReturningItems([], completionHandler: nil)
}
我已经看了很多其他的问题,但似乎无法找到任何符合我的使用情况。
答
当我明白这个问题我只是尽量回答你的问题:
请检查plist文件,如下图:
如果它不一样我建议再去做......
,我希望,有你的加入“应用组” 从选择项目 - >能力 ...
如果再没有工作上面提到的plist经过SUBQUERY为 如下:
<key>NSExtenstionActivationRule</key>
<string>SUBQUERY (
extensionItems,
$extensionItem,
SUBQUERY (
$extensionItem.attachments,
$attachment,
(
ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.image"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.plain-text"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.png"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg"
|| ANY $attachment.registeredTypeIdentifiers UTI-CONFORMS-TO "public.jpeg-2000"
)
)[email protected] == [email protected]
)[email protected] == 1
</string>
如果当时也没有工作,然后经过
App Extension by developer.apple.com
我认为,这将有助于...
感谢。我确实已经整理了这部分内容,它是保存到组共享文件夹的代码,我遇到了麻烦,尽管我已经回去并重新实现了与Obj C不同的方法。 – KenTenMen