PDA

View Full Version : opening my programme specific documents by double-click




Till Roenneberg
Aug 22, 2008, 07:29 AM
I am new to Cocoa programming and certainly far from being a professional programmer. I wrote a lot of programmes in the old OS 7-9 where the issue below was no problem.

In Cocoa, I don't know how to tell my programme (not document based) to open its own documents if they were double-clicked or dropped on the programme icon.

I am sure that the answer is quite simple but I have looked for weeks on the web and couldn't find anything that helped me with this problem. Any hint is greatly appreciated.

Thanks Till



robbieduncan
Aug 22, 2008, 07:50 AM
Have a read about UTI (http://developer.apple.com/macosx/uniformtypeidentifiers.html)s on the Apple site.

Till Roenneberg
Aug 22, 2008, 08:20 AM
Have a read about UTI (http://developer.apple.com/macosx/uniformtypeidentifiers.html)s on the Apple site.

Thanks. I have read this document (I am sure I still haven't done everything correctly).

The problem is not, however, that my programme doesn't start when I double-click one of its own files - it does that perfectly.

The problem is that I don't know what code to add so that the programme actually handles the file's content.


Thanks TIll

robbieduncan
Aug 22, 2008, 08:28 AM
Ah sorry, your question didn't make that clear (at least to me).

I think you probably want to look at the application:openFile: (http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSApplication_Class/Reference/Reference.html#//apple_ref/occ/instm/NSObject/application:openFile:) method available to the NSApplication delegate object...

Till Roenneberg
Aug 22, 2008, 06:37 PM
Thanks that was easy!