macosobjectcocoaunzipfindersync

How to give context menu item for .zip files only?


I am Developing the zip extractor app in cocoa for which i'm using findersync to show context menu item. But, the problem is item is showing for every file i want to show only for .zip files so how do i do that .

Any Suggestion.

Thanks in Advance!


Solution

  • Try this

    NSURL *selectedURL = FIFinderSyncController.defaultController.selectedItemURLs[0];
    NSURL *fileURL = selectedURL.filePathURL;
    if([fileURL.pathExtension isEqualToString:@"zip"]) {
      NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
      NSMenuItem *item = [menu addItemWithTitle:@"Hello" action:@selector(itemTarget:) keyEquivalent:@""];
      item.target = self;        
      return menu;
    }