2015-10-14 83 views
0

我工作的一個應用程序擴展,我想允許用戶與主機應用程序共享各種文件。保存文件宿主應用程序

實施例:挑選照片,通過應用選擇份額,照片保存到共享文件夾&然後可用時用戶下次打開主機應用程序。

我的主機應用程序已準備好從共享文件夾中讀取數據,而擴展名僅用圖像設置,但我堅持的是檢索文件數據(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) 
} 

我已經看了很多其他的問題,但似乎無法找到任何符合我的使用情況。

回答

0

當我明白這個問題我只是儘量回答你的問題:

請檢查plist文件,如下圖:

enter image description here

如果它不一樣我建議再去做......

,我希望,有你的加入「應用組」 從選擇項目 - >能力 ...


如果再沒有工作上面提到的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

我認爲,這將有助於...

+0

感謝。我確實已經整理了這部分內容,它是保存到組共享文件夾的代碼,我遇到了麻煩,儘管我已經回去並重新實現了與Obj C不同的方法。 – KenTenMen

相關問題