Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm not an authority on Growl, but I have a pretty good hunch: When the Growl app is installed, a one-shot notification like this has a prayer to work, because the running app has a run loop and can drive UI from it. In the example you have here, there's no run loop, so there's no way for this one-shot app to ever draw any notifications -- it's dead before it even has a chance. I would guess if you made a boilerplate Cocoa app, and then called <code>showGrowlMessage</code> from <code>applicationDidFinishLaunching:</code>, but before you terminated/quit the app, I bet it would work. At the very least you should give that a try.</p> <p>EDIT: If you create a new Cocoa non-document application, and add the following methods to the appDelegate class, it will successfully display a notification using the Mist (i.e. in-app) Growl.</p> <pre><code>@implementation SOAppDelegate @synthesize window = _window; - (void)showGrowlMessageTitled: (NSString*)title description:(NSString*) desc { NSLog(@"[Growl] showGrowlMessage() called."); NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; [GrowlApplicationBridge notifyWithTitle: title description: desc notificationName: @"Upload" iconData: nil priority: 0 isSticky: NO clickContext: nil]; [pool drain]; } - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [GrowlApplicationBridge setGrowlDelegate: (NSObject&lt;GrowlApplicationBridgeDelegate&gt;*)self]; [self showGrowlMessageTitled: @"Foo" description: @"Bar"]; } - (NSDictionary *) registrationDictionaryForGrowl { return [NSDictionary dictionaryWithObjectsAndKeys: [NSArray arrayWithObject: @"Upload"], GROWL_NOTIFICATIONS_ALL, [NSArray arrayWithObject: @"Upload"], GROWL_NOTIFICATIONS_DEFAULT, nil]; } @end </code></pre> <p>So, in short, the problem with the original code was not only the runLoop problem, but that it was not passing a real delegate (i.e. object that implements the delegate methods described in the headers as required) to the GrowlApplicationBridge (it passes an empty string). You definitely still need a runLoop, but that's not all -- there's additional, non-optional setup for using this framework.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload