Notification 날릴 때,
//Dictionary 만들어서 사용할 경우..
NSDictionary *infoData = [NSDictionary
dictionaryWithObjectsAndKeys:missionIdString, @"missionId",
winYNString, @"winYNString",
str1String, @"str1String",
str2String, @"str2String",
callbackString, @"callbackString",
nil];
[[NSNotificationCenter defaultCenter]
postNotificationName:@"NotificationLoadedBenefitView"
object:nil userInfo:infoData];
// 또는 한번에.. ㅋㄷ
[[NSNotificationCenter defaultCenter]
postNotificationName:@"NotificationLoadedBenefitView"
object:nil userInfo:@{@"missionId":missionIdString,
@"winYNString": winYNString,
@"str1String": str1String,
@"str2String": str2String,
@"callbackString": callbackString}];
Notification 받는 방법과 처리하는 메소드(selector)
// Notification 처리 메소드
- (void)updateBenefitView:(NSNotification *)notification
{
self.isWithCallback = YES;
[self viewMissionResult:notification];
NSDictionary *dict = [notification userInfo];
NSString *callbackString = [dict objectForKey:@"callbackString"];
[self performSelector:@selector(execCallback:)
withObject:callbackString afterDelay:1.0];
}
// Notification 옵저버
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(updateBenefitView:)
name:@"NotificationLoadedBenefitView" object:nil];
}
// Notification 제거
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}