How can I fetch object from NSNotification object? Any clue?
+1
A:
Quite simple. Use the object method of NSNotification.
- (void)myMethod:(NSNotification* notification) {
// Example with a NSArray
NSArray* myArray = (NSArray*)[notification object];
// Do stuff
}
Henrik P. Hessel
2010-10-02 02:51:56
A:
When you post you can wrap many objects in an NSDictionary.
NSDictionary *userInfo=[NSDictionary withObjectsAndKeys:obj1,key1,obj2,key2,nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"NOTI_NAME"
object:self
userInfo:userInfo];
In you observer:
-(void)notiObserver:(NSNotification *)notification{
NSDictionary *userInfo=[notification userInfo];
OBJ1 *obj1=[userInfo objectForKey:key1];
}
Jorge
2010-10-02 07:42:42
Thank you so much sir
Abhinav
2010-10-03 02:25:54