add finder service 1

If you don’t want to read Apple’s Service Implementation Guide or you just don’t have enough time, I’ll provide 3 simple steps to add your app to the Finder’s context menu as service.

Ok, Let’s do it.

How to add your app to the Finder’s context menu as service like is on the picture?

add finder service 2

 

Add Service record to your Info.plist fileadd finder service 3

 

Set ServicesProvider and update it with the code in the AppDelegate.m

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    [NSApp setServicesProvider:self];
    NSUpdateDynamicServices();
    
}

 

Implement handleServices method in the AppDelegate.m

- (void)handleServices:(NSPasteboard *)pboard
              userData:(NSString *)userData
                 error:(NSString **)error {
    if([[pboard types] containsObject:NSFilenamesPboardType]){
        NSArray* fileArray=[pboard propertyListForType:NSFilenamesPboardType];
        NSLog(@"fileArray:%@",fileArray);
        
        for (NSString *filePath in fileArray) {
            NSLog(@"%@", [filePath lastPathComponent]);
            
            /** do the jobe with selected items in Finder **/
        }
    }
}

That’s it.