【发布时间】:2010-03-22 15:06:29
【问题描述】:
我正在创建一个具有两种文档类型的 NSDocument 应用程序:网站和 Web 服务。这是在我的 Info.plist 中:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>Website</string>
<key>CFBundleTypeExtensions</key>
<array>
<string>website</string>
</array>
<key>LSTypeIsPackage</key>
<true/>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>NSDocumentClass</key>
<string>AWWebSite</string>
</dict>
<dict>
<key>CFBundleTypeName</key>
<string>Web Service</string>
<key>CFBundleTypeExtensions</key>
<array>
<string>webservice</string>
</array>
<key>LSTypeIsPackage</key>
<true/>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Default</string>
<key>NSDocumentClass</key>
<string>AWWebService</string>
</dict>
</array>
现在,每当用户打开应用程序,从菜单栏中选择“新建”项,或在没有打开的窗口时单击 Dock 图标时,我想显示一个包含两个选项的窗口,每个选项对应一个文档类型。谁能帮我这个?谢谢
【问题讨论】:
-
我猜您可能需要继承 NSDocumentController 并覆盖 newDocument: 方法,以便为您的窗口提供这些选项。您可以查看 Apple 关于基于文档的应用程序的文档。 developer.apple.com/Mac/library/documentation/Cocoa/Conceptual/…
标签: objective-c cocoa usability nsdocument