nac*_*o4d 9 iphone cocoa file-extension cocoa-touch
我的应用程序处理的文件类型*.mndl
不超过自定义*.plist
.到现在为止,我一直在使用*.plist
的文件,但现在我想扩展关联,能够打开*.mndl
从我已经意识到,重命名任何其他应用程序文件file.plist
,以file.mndl
不起作用.(因此,我甚至不知道我是否正确执行了扩展关联和导出事项)
我file.mndl
从计算机发送了一个文件,当我收到mail.app时,我得到了
file.mndl.plist
(它被自动重命名,这在重置我的iPad时发生了)
如何在能够使用+dictionaryWithContentsOfFile:
NSDictionary类读取其内容的同时创建自己的mndl文件?
即使我正在使用iOS,我相信这种东西都是从MacOS和Cocoa移植过来的.所以Cocoa开发人员也可以知道这一点.
您的意见/答案表示赞赏.
谢谢
回答:仅用于完成目的这是我对info.plist的补充:
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>Mandala Chart File</string>
<key>UTTypeIdentifier</key>
<string>com.nacho4d.Accordion.mndl</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>mndl</string>
</dict>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>Document320Icon.png</string>
<string>Document64Icon.png</string>
</array>
<key>CFBundleTypeName</key>
<string>Mandala Chart File</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.nacho4d.Accordion.mndl</string>
</array>
</dict>
</array>
Run Code Online (Sandbox Code Playgroud)
至少对于Cocoa(桌面)应用程序,您需要将以下信息添加到应用程序的Info.plist中.
http://www.markdouma.com/developer/nacho.plist
显然,您应该将统一类型标识符更改为适当的类型.(我通常做com.markdouma.something,因为那是我的网站).
请注意,如果您计划通过创建NSDocument子类来处理加载文件来计划使用Cocoa的NSDocument体系结构,那么您只想为NSDocumentClass指定一个条目.否则,您可以始终只实现以下<NSApplicationDelegate>(读取为应用程序委托协议)方法:
- (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames;
Run Code Online (Sandbox Code Playgroud)
这将为您提供NSArray NSStrings,表示用户在Finder中双击的文件的POSIX路径(或拖动到应用程序图标等)
如果要转到NSDocument路由,可以覆盖以下NSDocument方法
- (BOOL)readFromURL:(NSURL *)url ofType:(NSString *)type error:(NSError **)outError;
Run Code Online (Sandbox Code Playgroud)
用[[NSDictionary dictionaryWithContentsOfFile:[url path]] retain]创建你的字典;
希望这可以帮助...
归档时间: |
|
查看次数: |
6175 次 |
最近记录: |