iOS消息通知Notification的用法

1.发送消息

1 NSNotification *notification = [NSNotification notificationWithName:@"selectPosition" object:nil userInfo:@"codeABC" forKey:@"code"];
2 [[NSNotificationCenter defaultCenter]postNotification:notification];

2.接收消息

1 - (void)viewDidLoad {
2     [super viewDidLoad];  
3     [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(selectPosition:) name:@"selectPosition" object:nil];
4 }
5 
6 - (void)selectPosition:(NSNotification *)notification
7 {
8     NSString *code = [notification.userInfo objectForKey:@"code"];
9 }

 

iOS消息通知Notification的用法

上一篇:Android 世界中,谁喊醒了 Zygote ?


下一篇:android图片缓存框架Android-Universal-Image-Loader