블로그/아이폰/iOS
[NSNotificationCenter 사용법] viewController끼리 데이터 주고받을 때
EntusApps
2014. 8. 29. 16:18
1. 노티 보내기
1-1) 데이터 없이 노티만 보내기
[[NSNotificationCenter defaultCenter]postNotificationName:@"notiName" object:nil];
1-2) 노티에 데이터 실어 보내기
[[NSNotificationCenter defaultCenter]postNotificationName:@"notiName" object:nil userInfo:@{보낼 딕셔너리}];
2. 노티 받기
NSNotificationCenter *notiCenter = [NSNotificationCenter defaultCenter];
[notiCenter addObserver:self selector:@selector(notiSelName:) name:@"notiName" object:nil];
-(void)notiSelName:(NSNotification*)noti{
NSDictionary *info = [noti userInfo];
}