#import <Foundation/Foundation.h>

@interface NCTest : NSObject
{
  NSUInteger counter;
}
@end

@implementation NCTest

- (void) notified: (NSNotification *) notif
{
  NSLog (@"%@", notif);
  counter++;
}

- (NSUInteger) getCounter
{
  return counter;
}
@end

int
main (void)
{
  CREATE_AUTORELEASE_POOL (pool);
  NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
  NCTest *object = AUTORELEASE ([NCTest new]);
  NSObject *obj = AUTORELEASE ([NSObject new]);

  [nc addObserver: object
  	 selector: @selector (notified:)
  	     name: @"Notification"
  	   object: nil];

  [nc postNotificationName: @"Notification" object: obj];
  [nc postNotificationName: @"Notification" object: nil];
  [nc postNotificationName: @"Foo" object: nil];
  [nc removeObserver: object];
  [nc postNotificationName: @"Notification" object: obj];

  GSPrintf (stdout, @"Posting a simple notification appears to work.\n"
	    @"Total notifications: %d\n", [object getCounter]);

  RELEASE (pool);
  exit (EXIT_SUCCESS);
}
