2010-11-15 61 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
相关问题