2010-10-02 2 views

ответ

3

Когда вы отправляете сообщение, вы можете обернуть множество объектов в NSDictionary.

NSDictionary *userInfo=[NSDictionary withObjectsAndKeys:obj1,key1,obj2,key2,nil]; 
[[NSNotificationCenter defaultCenter] postNotificationName:@"NOTI_NAME" 
                object:self 
                userInfo:userInfo]; 

В вас наблюдатель:

-(void)notiObserver:(NSNotification *)notification{ 

    NSDictionary *userInfo=[notification userInfo]; 
    OBJ1 *obj1=[userInfo objectForKey:key1]; 

} 
+0

Большое вам спасибо, сэр – Abhinav

2

Довольно просто. Используйте метод объекта NSNotification.

- (void)myMethod:(NSNotification* notification) { 
    // Example with a NSArray 
    NSArray* myArray = (NSArray*)[notification object]; 
    // Do stuff 
} 
Смежные вопросы