iOS开发 NSNotificationCenter 通知的使用方法
2016-10-25 14:32
232 查看
//发送通知到 (在需要的地方发送通知, 信息储存在userInfo(字典类型))
[[NSNotificationCenter
defaultCenter] postNotificationName:NSNOTIFICATION_TAG
object:self
userInfo:userInfo];
//z在需要的地方接受通知
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(messageNotifacation:)
name:NSNOTIFICATION_TAG
object:nil];
//方法
- (void)messageNotifacation:(NSNotification
*)notification {
NSDictionary *userInfo = notification.userInfo;
信息可以从userInfo中取出
}
注:"NSNOTIFICATION_TAG" 我们自定义的标识符
[[NSNotificationCenter
defaultCenter] postNotificationName:NSNOTIFICATION_TAG
object:self
userInfo:userInfo];
//z在需要的地方接受通知
[[NSNotificationCenter
defaultCenter] addObserver:self
selector:@selector(messageNotifacation:)
name:NSNOTIFICATION_TAG
object:nil];
//方法
- (void)messageNotifacation:(NSNotification
*)notification {
NSDictionary *userInfo = notification.userInfo;
信息可以从userInfo中取出
}
注:"NSNOTIFICATION_TAG" 我们自定义的标识符
相关文章推荐
- iOS开发之NSNotificationCenter(通知)的使用方法
- iOS开发之:NSNotificationCenter(通知)的使用方法
- iOS开发之NSNotificationCenter(通知)的使用方法
- ios 开发视图的tag使用方法
- 【iOS-Cocos2d游戏开发之十一】使用Box2d物理系统以及在cocos2d框架添加Box2d物理系统lib包的方法
- cocos2d-x 中的pvr.ccz压缩图片的使用方法【iOS游戏开发征文】
- 【iOS-Cocos2d游戏开发之十一】使用Box2d物理系统以及在cocos2d框架添加Box2d物理系统lib包的方法 推荐
- iPhone开发之NSNotificationCenter(通知)的使用方法
- iOS开发OC基础:OC字典NSDictionary以及NSMutableDictionary基本方法的使用
- cocos2d-x 中的pvr.ccz压缩图片的使用方法【iOS游戏开发征文】
- iOS开发>>>openURL的使用方法
- Delphi for iOS开发指南(13):在iOS Device中使用通知中心
- iOS游戏开发中使用自定义字体的方法
- iOS开发之Core Graphics相关方法的简单使用
- iOS开发OC基础:OC集合NSSet、NSMutableSet以及NSCountedSet的基本方法的使用
- Delphi for iOS开发指南(13):在iOS Device中使用通知中心
- 【iOS-Cocos2d游戏开发之十一】使用Box2d物理系统以及在cocos2d框架添加Box2d物理系统lib包的方法
- IOS开发---菜鸟学习之路--(六)-UITableView几个方法的使用说明
- ios 开发 iphone和ipad程序中使用google地图的方法
- iOS开发OC基础:OC字符串对象NSString对象方法使用基础