Page 1 of 1

Simple example project?

Posted: Wed Oct 10, 2007 2:17 am
by CompiledMonkey
Is there a simple example out there on how to use growl? I'm not getting anywhere with the current docs.

Posted: Wed Oct 10, 2007 3:35 am
by evands
The BeepHammer project in the Developer Tools folder of the source is a pretty straightforward usage example.

Posted: Wed Oct 10, 2007 1:26 pm
by CompiledMonkey
&OK, here's what I have currently. The error I'm getting at run time is: "*** Uncaught exception: <NSInvalidArgumentException> *** +[GrowlApplicationBridge notifyWithTitle:description:notificationName:]: selector not recognized". Any idea what I'm doing wrong?

GrowlController.h

Code: Select all

#import <Cocoa/Cocoa.h>
#import <Growl-WithInstaller/Growl.h>

@interface GrowlController: NSObject<GrowlApplicationBridgeDelegate>
{
	
}

@end
GrowlController.m

Code: Select all

#import "GrowlController.h"

#define SampleNotificationName  @"The HelloGrowl Sample Notification"
#define GROWL_NOTIFICATION_DEFAULT @"NotificationDefault;

@implementation GrowlController

- (void) awakeFromNib {
	[GrowlApplicationBridge setGrowlDelegate:self];
	//[GrowlApplicationBridge reregisterGrowlNotifications];
	
	//NSDictionary *prefsDict = [[NSDictionary alloc] initWithContentsOfFile:GROWL_PREFS_PATH];
	//[growlLoggingButton setState:[[prefsDict valueForKey:@"GrowlLoggingEnabled"] intValue]];
}

- (NSString *)applicationNameForGrowl {
	return @"BeepHammer";
}

- (NSDictionary *) registrationDictionaryForGrowl
{
    NSArray *notifications = [NSArray arrayWithObjects:
            SampleNotificationName,
            nil];
	
    NSDictionary *regDict = [NSDictionary dictionaryWithObjectsAndKeys:
            @"Weather", GROWL_APP_NAME,
            notifications, GROWL_NOTIFICATIONS_ALL,
            notifications, GROWL_NOTIFICATIONS_DEFAULT,
            nil];
	
    return regDict;
}

- (void) sendMessage {
	[GrowlApplicationBridge notifyWithTitle:"Title"
                                description:"Description"
                           notificationName:SampleNotificationName];
}

@end
main.m

Code: Select all

#import <Cocoa/Cocoa.h>
#import "GrowlController.h"

int main(int argc, char *argv[])
{
	GrowlController *cont = [[GrowlController alloc] init];
	[cont sendMessage];
	
    return NSApplicationMain(argc,  (const char **) argv);
}