2010-11-15 67 views
15

我目前正在創建一個應用程序,我想讓用戶備份他們的文件(plist + m4a)。我壓縮文件並將擴展名更改爲自定義文件(專門用於我的應用程序,例如「* .MyBackup」)。用戶可以通過電子郵件或通過iTunes文件共享進行導出。如何在iOS中註冊自定義文件類型

我已經閱讀了關於CFBundleDocumentTypes的內容,但並沒有真正瞭解我必須要做的事情。

我目前堅持的部分是如何將我的擴展與我的應用相關聯。如果用戶發送一封帶有「custom」-zip文件的電子郵件,他應該可以用我的應用程序打開它。

我該如何做,以及「UTExportedTypeDeclarations」是什麼?

+0

可能重複://計算器.com/questions/2774343/how-do-i-associate-file-types-with-an-iphone-application) – 2010-11-15 17:28:01

回答

28

我希望沒關係,如果我在我的項目info.plist的那部分轉儲沒有太多進一步的解釋。我認爲這非常明瞭。

<key>CFBundleDocumentTypes</key> 
<array> 
    <dict> 
     <key>CFBundleTypeIconFiles</key> 
     <array> 
      <string>Icon-iPad-doc320.png</string> 
      <string>Icon-iPad-doc.png</string> 
     </array> 
     <key>CFBundleTypeName</key> 
     <string>MyAppName File</string> 
     <key>CFBundleTypeRole</key> 
     <string>Viewer</string> 
     <key>LSHandlerRank</key> 
     <string>Owner</string> 
     <key>LSItemContentTypes</key> 
     <array> 
      <!-- my app supports files with my custom extension (see UTExportedTypeDeclarations) --> 
      <string>com.myurl.myapp.myextension</string> 
      <!-- and csv files. --> 
      <string>public.comma-separated-values-text</string> 
     </array> 
    </dict> 
</array> 



<key>UTExportedTypeDeclarations</key> 
<array> 
    <dict> 
     <key>UTTypeConformsTo</key> 
     <array> 
      <string>public.data</string> 
     </array> 
     <key>UTTypeDescription</key> 
     <string>MyAppName File</string> 
     <key>UTTypeIdentifier</key> 
     <string>com.myurl.myapp.myextension</string> 
     <key>UTTypeTagSpecification</key> 
     <dict> 
      <key>public.filename-extension</key> 
      <string>myextension</string> 
      <key>public.mime-type</key> 
      <string>application/octet-stream</string> 
     </dict> 
    </dict> 
</array> 
+0

真棒,它的工作原理!感謝您的快速響應... – JNK 2010-11-15 16:46:40

+0

請務必檢查答案旁邊的複選標記。 – 2010-11-15 16:50:46

+0

ahhh ... ok:D stil a complete n00b:D – JNK 2010-11-15 16:55:37

2

退房/var/mobile/Library/Preferences/com.apple.LaunchServices.plist

的[我如何將文件類型與iPhone應用程序相關聯?(HTTP
相關問題