2012-08-14 4 views
0
[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(requestAddressUpdatedNotification:) 
              name:MTAddressUpdatedNotification 
              object:nil]; 

내 프로그램에서이 코드를 작성하면 어떤 일이 일어날 지 아무에게도 알려 줄 수 있습니까?이 코드 조각의 의미는 무엇입니까?

언제 requestAddressUpdatedNotification이라고 할 수 있습니까?

+0

[옵서버 패턴] (http://en.wikipedia.org/wiki/Observer_pattern)을 보길 원할 수도 있습니다. –

답변

4

코드는 MTAddressUpdatedNotification NSNotification가 발생했을 때 개체 (self)를 통지하고 같은 클래스 (@implementation…@end 이내)을 정의해야합니다 requestAddressUpdatedNotification: 방법을 실행하는 데 기본 NSNotificationCenter을 알려줍니다.

+0

그러면 MTAddressUpdatedNotification이 발생하고 requestAddressUpdatedNotification이 호출됩니다. – generalzyq

+0

예, MTAddressUpdatedNotification이 게시되면 requestAddressUpdatedNotification :이 트리거되거나 Objective-C 용어 "메시지 수신"이 트리거됩니다. –

+0

대단히 감사합니다! ~ – generalzyq

관련 문제