SquidCombo Posted April 8, 2008 Share Posted April 8, 2008 Does anyone know how to handle files with finder "open with" in our program? Say someone wants to open .png pictures with our program. What gets called first? Do we use pasteboards to handle this? Thanks in advance. Link to comment https://www.insanelymac.com/forum/topic/98173-handling-files-open-with-from-finder/ Share on other sites More sharing options...
westwaerts Posted April 9, 2008 Share Posted April 9, 2008 Does anyone know how to handle files with finder "open with" in our program? Say someone wants to open .png pictures with our program. What gets called first? Do we use pasteboards to handle this? Thanks in advance. its handled by filetype and creator, edited in finderflags, creatorchanger is an app for it. unlike windows they arent visible Link to comment https://www.insanelymac.com/forum/topic/98173-handling-files-open-with-from-finder/#findComment-702301 Share on other sites More sharing options...
PascalW Posted April 9, 2008 Share Posted April 9, 2008 Does anyone know how to handle files with finder "open with" in our program? Say someone wants to open .png pictures with our program. What gets called first? Do we use pasteboards to handle this? Thanks in advance. What language? For objective-C look at NSApp: - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename; - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames; Link to comment https://www.insanelymac.com/forum/topic/98173-handling-files-open-with-from-finder/#findComment-702660 Share on other sites More sharing options...
SquidCombo Posted April 10, 2008 Author Share Posted April 10, 2008 Dear westwaerts: How do I edit the finderflags? Is it like one of those document based cocoa project where there's a file which you can edit to specify the filetypes your app would handle? Dear PascalW: It'll be obj-c. I think your solution is what I'm looking for. Thanks! Link to comment https://www.insanelymac.com/forum/topic/98173-handling-files-open-with-from-finder/#findComment-703487 Share on other sites More sharing options...
SquidCombo Posted April 14, 2008 Author Share Posted April 14, 2008 Hi PascalW, your solution works! and it's pretty nice considering it won't launch another instance of my app if one is already running. My problem right now is registering the recommended file type. Right now I would get a message saying "It is not known if this application can open PNG files" and my app can only be chosen if I choose All Applications in the enable combo box. Anyone knows a solution? And my guess that it would allow dropping files into my app icon on the dock once I register the file type handling to finder? Link to comment https://www.insanelymac.com/forum/topic/98173-handling-files-open-with-from-finder/#findComment-708155 Share on other sites More sharing options...
PascalW Posted April 15, 2008 Share Posted April 15, 2008 My problem right now is registering the recommended file type.... Anyone knows a solution? And my guess that it would allow dropping files into my app icon on the dock once I register the file type handling to finder? Yes you should register your app as being a editor/viewer for a filetype. Put something like this in your info.plist: <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeExtensions</key> <array> <string>png</string> </array> <key>CFBundleTypeIconFile</key> <string>png</string> <key>CFBundleTypeName</key> <string>png</string> <key>CFBundleTypeOSTypes</key> <array> <string>png</string> </array> <key>CFBundleTypeRole</key> <string>Viewer</string> <key>LSTypeIsPackage</key> <false/> <key>NSPersistentStoreTypeKey</key> <string>XML</string> </dict> </array> You could also specify this in Xcode, somewhere in project or active target settings. And yes, if you register your app like this, the registrerd filetypes can also be dropped on the dock icon. Link to comment https://www.insanelymac.com/forum/topic/98173-handling-files-open-with-from-finder/#findComment-709235 Share on other sites More sharing options...
SquidCombo Posted April 15, 2008 Author Share Posted April 15, 2008 PascalW, thank you so much!!! It now works on my app. Is there a documentation for this? I can't seem to find it on the adc site. I'll go through the part for the packaging and deployment i guess. Thank you so much PascalW. Link to comment https://www.insanelymac.com/forum/topic/98173-handling-files-open-with-from-finder/#findComment-710317 Share on other sites More sharing options...
Recommended Posts