首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

NSNotificationCenter漫笔

2012-09-27 
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:@""];

热点排行