나름 프로그래밍?/ Objective-C
NSNotification
-Dong-
2010. 5. 7. 17:35
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
- Notification 받기
[nc addObserver:self selector:@selector(myMethod:) name:@"myNotiName" object:nil];
- Notification 날리기
[nc postNotificationName:@"myNotiName" object:self userInfo:nil];
- Notification 해제
[nc removeObserver:self name:@"myNotiName" object:nil];
메소드 선언은 다음과 같이
- Notification 받기
[nc addObserver:self selector:@selector(myMethod:) name:@"myNotiName" object:nil];
- Notification 날리기
[nc postNotificationName:@"myNotiName" object:self userInfo:nil];
- Notification 해제
[nc removeObserver:self name:@"myNotiName" object:nil];
메소드 선언은 다음과 같이
-(void)myMethod:(NSNotification *)noti{
NSString *stringValue = [[noti userInfo] objectForKey:@"inputKey"];
}
값담기
NSDictionary *dic = [NSDictionary dictionaryWithObject:_textField.text forKey:@"key"];
가져올땐
NSString *text = [[note userInfo] objectForKey:@"key"];