Is it possible to show an error dialog from with in a finder extension?

I would like to be able to display an error message if one of my context menu actions fails.

I have tried doing something like this but it doesn't seem to work:

Code Block
- (IBAction)contextAction:(NSMenuItem *)sender {
NSAlert *alert = [[NSAlert alloc]init];
[alert setMessageText:@"A dialog"];
[alert setInformativeText:@"A message"];
[alert setAlertStyle:NSWarningAlertStyle];
[alert runModal];
[myFinderSync performMenuItemAction:(uint32_t)sender.tag];
}



Replies

FinderSync extensions are not expected to show UI directly. If you need to alert the user, post a local notification using User Notifications. If the user interaction is more complex, the user can click through your notification to launch your container app.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

This is what we are doing:

class EntryPoint: FIFinderSync {

   private var windowController: MainWindowConreoller?

   override func menu(for menuKind: FIMenuKind) -> NSMenu {
      let menu = NSMenu(title: "")
      menu.addItem(withTitle: "Example Menu Item", action: #selector(openMainWindow(_:)), keyEquivalent: "")
      return menu
   }

   @objc private func openMainWindow(_ sender: AnyObject?) {
      DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { // [1] Switch to main thread !!!
         NSApplication.shared.activate(ignoringOtherApps: true) // [2] Activate App !!!
         let wc = MainWindowConreoller()
         wc.showWindow(nil)
         self.windowController = wc // [3] Retain window controller !!!
      }
   }
}

Working App example:

This is what we are doing

I recommend against this. Finder Sync extensions are meant to operate in the background, and the best way for background code to request user interaction is via a notification. Yanking yourself to the front like this is seriously impolite.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"