//通知送信 NSNotification *notification = [NSNotification notificationWithName:@"hoge" object:self]; [[NSNotificationCenter defaultCenter] postNotification:notification];
受信
//通知受信 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(test) name:@"hoge" object:nil]; //呼ばれる関数 - (void)test { NSLog(@"notification!"); }
削除
- (void) dealloc { //通知受信の削除 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; [nc removeObserver:self name:@hoge" object:nil]; [super dealloc]; }
0 件のコメント:
コメントを投稿