iphone – 基于plist创建我自己的文件扩展名

iphone – 基于plist创建我自己的文件扩展名,第1张

概述我的应用程序处理类型为* .mndl的文件,该文件不超过自定义* .plist. 到目前为止,我一直在使用* .plist文件,但现在我想关联扩展并能够从任何其他应用程序打开* .mndl文件我已经意识到将file.plist重命名为file.mndl不起​​作用. (因此,我甚至不知道我是否正确执行了扩展关联和导出事项) 我从计算机发送了一个文件file.mndl,当我收到mail.app时,我 @H_419_0@ @H_419_0@ 我的应用程序处理类型为* .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>
解决方法 至少对于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;

这将为您提供NSArray Nsstrings,表示用户在Finder中双击的文件的POSIX路径(或拖动到应用程序图标等)

如果要转到NSdocument路由,可以覆盖以下NSdocument方法

- (BOol)readFromURL:(NSURL *)url ofType:(Nsstring *)type error:(NSError **)outError;

用[[NSDictionary dictionaryWithContentsOffile:[url path]] retain]创建你的字典;

希望这可以帮助…

@H_419_0@ 总结

以上是内存溢出为你收集整理的iphone – 基于plist创建我自己的文件扩展名全部内容,希望文章能够帮你解决iphone – 基于plist创建我自己的文件扩展名所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1033061.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存