2011-01-12 2 views
0

하나의 알림을 게시하고 두 개의 서로 다른 개체가 두 가지 다른 방법을 실행하도록 할 수 있습니까?여러 개체에 대한 단일 알림?

[[NSNotificationCenter defaultCenter] postNotificationName:@"locationAdded" object:nil]; 

OBJECT ONE :

[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(reloadAnnotations:) 
              name:@"locationAdded" 
              object:nil]; 

OBJECT 2 :

[[NSNotificationCenter defaultCenter] addObserver:self 
             selector:@selector(reloadAnnotations:) 
              name:@"locationAdded" 
              object:nil]; 

. . . 내가 의심으로


가 아니면 것 I는 고유 한 이름 (예)

[[NSNotificationCenter defaultCenter] postNotificationName:@"updateTable" object:nil]; 
[[NSNotificationCenter defaultCenter] postNotificationName:@"updateMapView" object:nil]; 

답변

4

알림은 게시하기 전에 추가 된 각 옵저버에게 전달됩니다. 하나의 알림 만 필요합니다. 선택기는 다를 수 있습니다.

+0

및 전화 [[NSNotificationCenter defaultCenter] postNotificationName : @ "locationAdded"개체 : 없음]; – Andriy

2

아니, 괜찮아요 두 개의 별도의 통지를 게시 할 필요가 등록로서, 하나의 통지는 많은 관찰자에게 전달 그것을 위해.

관련 문제