One Quickie


Adding Growl Notifications (Random->General)
It's pretty easy adding growl notifications to your app. Download the SDK from growl.info. Set up your Xcode project to copy the Growl.framework into your application bundle.

Pick a class to be the contact point with Growl. Your AppController class is a good place. Import <Growl/Growl.h>

Set the delegate to the GrowlApplicationBridge:

    [GrowlApplicationBridge setGrowlDelegate: self];
Doing this will eventually have the registrationDictionaryForGrowl delegate message called. Return a dictionary with two arrays (Which can be the same). These are the names of the alerts you will be posting. These are human-readable, so you'll want to use a localized string (which I've already set in the global variable here:
- (NSDictionary *) registrationDictionaryForGrowl
{
    NSArray *notifications;
    notifications = [NSArray arrayWithObject: g_timesUpString];

    NSDictionary *dict;

    dict = [NSDictionary dictionaryWithObjectsAndKeys:
                             notifications, GROWL_NOTIFICATIONS_ALL,
                         notifications, GROWL_NOTIFICATIONS_DEFAULT, nil];

    return (dict);

} // registrationDictionaryForGrowl
And use this to post a notification:
[GrowlApplicationBridge notifyWithTitle: @"Woop!  Time has expired!"
                        description: @"You have been waiting for 37 minutes"
                        notificationName: g_timesUpString
                        iconData: nil
                        priority: 0
                        isSticky: NO
                        clickContext: nil];
Consult the SDK documentation for more explanations of the features, but they are pretty self-explanitory.



borkware home | products | miniblog | rants | quickies | cocoaheads
Advanced Mac OS X Programming book

webmonster@borkware.com