Let the user select the type of document to open.

I am creating an NSDocument application with two types of documents: website and web service. This is in my 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>

Now, when the user opens the application, selects the "New" item from the menu bar or clicks the "Dock" icon until there are no open windows, I want to show a window with two parameters, each for one of the documents types. Can anyone help me with this? Thanks

+3
source share
1 answer

, - [NSDocumentController newDocument:]. NSDocumentController , newDocument:, .

, , makeUntitledDocumentOfType:error:, addDocument:, makeWindowControllers showWindows. , openUntitledDocumentAndDisplay:error:.

, NSDocumentController , , , Apple. , , MainMenu.xib , NIB . , , .

+5

Source: https://habr.com/ru/post/1738044/


All Articles