NSNotificationCenter漫笔

NSNotificationCenter随笔可在AppDelegate.h中定义,之后可全局使用。NSNotificationCenter *notificationCe

NSNotificationCenter随笔
    可在AppDelegate.h中定义,之后可全局使用。

NSNotificationCenter *notificationCenter;

在.m文件中:

- (void)applicationDidFinishLaunching:(UIApplication *)application{    self.notificationCenter = [NSNotificationCenter defaultCenter];[notificationCenter addObserver:self selector:@selector(trackNotifications:) name:nil object:nil];}- (void) trackNotifications: (NSNotification *) notification{id nname = [notification name];if([nname isEqual:@"***"]){......}else if([nname isEqual:@"***"]){......}else if([nname isEqual:@"***"]){......}else if([nname isEqual:@"***"]){......}else if([nname isEqual:@"***"]){......}}


      在别的地方使用的时候,只需要调用[[NSNotificationCenter defaultCenter] postNotificationName:@"about" object:@""];