objective c - Setting default application for given file extension on Mac OS X from code -


I have a list of applications for file extensions (by using LSCopyApplicationURLsForURL) I have one of the above calls I want to change the default file association with the code to choose from. Is there any way to do this?

Here is the snippet of code for a very relevant task: set your given file extension As the default application to you:

  #import & lt; ApplicationServices / ApplicationServices.h & gt; #import "LaunchServicesWrapper.h" @implementation LaunchServicesWrapper + (NSString *) UTIforFileExtension: (NSString *) extension {NSString * UTIString = (NSString *) UT touch creole reversed identifier (KUTTagClassFilenameExtension, (CFStringRef) extension, NULL); Return [UTISTing Autourage]; } + (BOOL) setMyselfAsDefaultApplicationForFileExtension: (NSStatus *) File Extension (OSStatus returnStatus = LSSetDefaultRoleHandlerForContentType) [UTIFile Extension: File Extension on Launch Services], KLSolarLL, (CF Stringerf) [[NSBindal Main Bundle] Bundle Identifier]; If (return status! = 0) {NSLog (found an error when setting the default application -% d ", return status); // Please see the documentation or LSInfo.h return number;} return yes;} @end  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -