안녕하세요, 알림 센터를 통해 메시지를 보내는 NSObject 하위 클래스가 있습니다. 내 알림을 객체 nil로 보낼 수 있지만 가능한 유일한 객체입니다. 알림을 수신하는 I 동시에 발송되는 두 개의 알림을 가지고NSNotifications가 동일한 객체 내에서만 전송됩니다.
그들에게 보내는 하나입니다
[[NSNotificationCenter defaultCenter] postNotificationName:kWGAskingForAuthToken object:nil];
int status = 123;
NSDictionary *userInfo = [NSDictionary dictionaryWithObject:@"RAR" forKey:@"Status"];
NSNotification *note = [NSNotification notificationWithName:kWGAskingForAuthToken object:nil userInfo:userInfo];
[[NSNotificationCenter defaultCenter] performSelectorOnMainThread:@selector(postNotification:) withObject:note waitUntilDone:YES];
를 (그것이 스레딩 문제의 경우 테스트) 내 관찰자는 간단하다
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleMyEvent:)name:kWGAskingForAuthToken object:nil];
알림을 수신하지 않는 별도의 개체에있는 동일한 관찰자입니다.
나는 그것이 무엇 좀 실망하게하는 것은 내가 수백하지만 결코 내 자신의 을 메아리 중심을 통과하는 모든 알림의 로그를 가지고있다 (둘 다 포함했다있는 NSString 상수로) 제대로 정의 두려워 ([[NSNotificationCenter defaultCenter] addObserver : 셀렉터 : @selector (로그 :) name : nil object : nil];) – orta