Question

In creating some .mov files using Cocoa (Obj-C), I'd like to set them to be opened by default by a specific program, instead of the default. This should be a file level property, I do not wish to change the default program for all files with the same extension. This is to be done from Cocoa itself, as opposed to manually in "context menu">>"Get Info">>"Open With".

Was it helpful?

Solution

There's an undocumented function call that sets this:

// undocumented function call

extern OSStatus _LSSetStrongBindingForRef(const FSRef *inItemRef,
                                          FSRef *inAppRefOrNil);

*If you use this in your application and submit it to the AppStore it will probably get rejected.

OTHER TIPS

As an intermediate between doing it by hand and doing it from Cocoa, there is an Automator action called "Set Application for Files".

I don't think there is a supported way to do it programmatically, but some people have figured out what Finder is doing: Adding a resource of type 'usro' that contains a full path to the application. See for example this discussion. Note: the Resource Manager is deprecated as of 10.8.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top