In the sender class, you can send a notification with an object with something like this:
[[NSNotificationCenter defaultCenter] postNotificationName: NOTIFICATION_NAME object: myString];
The listener or recipient class must register to notify:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(incomingNotification:) name:NOTIFICATION_NAME object:nil];
IncomingNotification Method:
- (void) incomingNotification:(NSNotification *)notification{ NSString *theString = [notification object]; ... }
EDIT
When you send a notification from "ViewController", does "ViewController2" load?
Jonathan naguin
source share