You can pass data in the userDictionary element of the API call
NSDictionary *aDictionary = [[NSDictionary alloc] initWithObjectsAndKeys: anObject, @"objectName", anotherObject, @"objectId", nil] autorelease]; [[NSNotificationCenter defaultCenter] postNotificationName:@"AnythingAtAll" object:nil userInfo:aDictionary];
You can get the dictionary from the incoming notification that you are observing. Add an observer before sending a notification.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(anyAction:) name:@"AnythingAtAll" object:nil];
it could be in your init method or viewDidLoad method
-(void)anyAction:(NSNotification *)anote { NSDictionary *dict = [anote userInfo]; AnyClass *objectIWantToTransfer = [dict objectForKey:@"objectName"]; }
note that you must delete your object as an observer in the dealloc method.
[[NSNotificationCenter defaultCenter] removeObserver:self]
source share