Drag file app to dock icon - hewigovens/hewigovens.github.com GitHub Wiki

Step 1

Add CFBundleDocumentTypes to your Info.plist

Old style, Accept files based on extensions, CFBundleTypeExtensions Deprecated in OS X v10.5

<key>CFBundleDocumentTypes</key>
<array>
	<dict>
	    <key>CFBundleTypeExtensions</key>
	    <array>
		<string>*</string>
	    </array>
	    <key>CFBundleTypeRole</key>
	    <string>Viewer</string>
	    <key>CFBundleTypeName</key>
	    <string>All Files</string>
	</dict>
	</array>

Or new style, use UTI

<key>CFBundleDocumentTypes</key>
<array>
	<dict>
	    <key>LSItemContentTypes</key>
	    <array>
		<string>com.apple.application</string>
	    </array>
	    <key>CFBundleTypeRole</key>
	    <string>Viewer</string>
	    <key>CFBundleTypeName</key>
	    <string>Application Viewer</string>
        </dict>
</array>

Full lists: System-Declared Uniform Type Identifiers

Step 2

implement -(BOOL)application:(NSApplication *)sender openFile:(NSString *)filename; or - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames; in NSApplicationDelegate

⚠️ **GitHub.com Fallback** ⚠️