В 13:24 +0200 на 03.02.2010 (ср), Yavor Doganov написа:
> compile he attached program with "gs_make"
Sorry; I sent you the wrong program. Here is nctest.m.
BTW, it might be useful to run test.m too, I wrote it once to detect an
obscure 64-bit bug which manifested itself in Emacs.app. Run
./obj/test '{a=b; c=d}' '(foo, bar)' --batch '(setq foo 1)'
(You have to adapt the variables in the GNUmakefile to match the tool
name "test".)
#import <Foundation/Foundation.h>
@interface NCTest : NSObject
NSUInteger counter;
@end
@implementation NCTest
- (void) notified: (NSNotification *) notif
{
NSLog (@"%@", notif);
counter++;
}
@end
int
main (void)
{
CREATE_AUTORELEASE_POOL (pool);
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NCTest *object = [NCTest new];
NSObject *obj = [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", counter);
RELEASE (pool);
exit (EXIT_SUCCESS);
}