NSString *const GameToiphoneNotification = @"GameToIPhoneNotification"; GameToIPhoneNotification變量,@"GameToIPhoneNotification"這個值存于通知中心中,信息中心通過這個值來識別變量
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(onToIphone:) name:GameToIPhoneNotification object:nil];
-(void)onToIphone:(NSNotification*)notify :這個方法是接受到GameToIPhoneNotification這個通知所調用的方法
2.調用信息
NSNotificationCenter * center = [NSNotificationCenter defaultCenter];
[center postNotificationName:GameToIPhoneNotification object:nil userInfo:[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:SMSRecommendNotification] , @"actcode",nil]];
[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:SMSRecommendNotification] 這個是傳遞給-(void)onToIphone:(NSNotification*)notify 的參數。
新聞熱點
疑難解答