概述
NSString *const GameToIPhoneNotification = @"GameToIPhoneNotification"; GameToIPhoneNotification变量,@"GameToIPhoneNotification"这个值存于通知中心中,信息中心通过这个值来识别变量
1.注册一个消息中心
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 的参数。
转自http://blog.csdn.net/zu12jing/article/details/5772301
转载于:https://www.cnblogs.com/jiangshiyong/archive/2013/01/31/2886704.html
最后
以上就是开朗帆布鞋为你收集整理的通知postNotificationName 消息传递详解的全部内容,希望文章能够帮你解决通知postNotificationName 消息传递详解所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复