拖拽文件到dock上面的icon来打开需要两个操作:
1、代码
在AppDelegate.m里面添加delegate函数:
- (void)application:(NSApplication *)theApplication openFiles:(NSArray *)filenames
这个函数会自动被调用。
2、Info.plist
向Info.plist里面添加代码:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>*</string>
</array>
<key>CFBundleTypeName</key>
<string>Folder</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>****</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSTypeIsPackage</key>
<false/>
</dict>
</array>
一开始我只添加了代码部分,结果不行,最后又添加了Info.plist部分,感觉苹果应该让步骤更简单点,添加代码部分就可以了,为何还要添加Info.plist部分。