, , string1 in. - , . ViewController1 vc1 ViewController2 vc2, , , :
[vc1 setString1:[vc2 string2]]
string1 , ViewController2, . ViewController1 :
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aChangeStringMethod:) name:@"anyStringJustMakeItUnique" object:nil];
:
-(void)aChangeStringMethod:(NSNotification)notification{
string1 = [((ViewController2 *)[notification object]) string2];
}
ViewController2, :
[[NSNotificationCenter defaultCenter] postNotificationName:@"anyStringJustMakeItUnique" withObject:self];
, , vc2, vc1. ViewController1 , , :
[[NSNotificationCenter defaultCenter] postNotificationName:@"anyStringJustMakeItUnique" withObject:vc2];
- ViewController1 (, vc2). : , ViewController2:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(launchTheOtherNotificationMethod:) name:@"anotherNotificationName" object:nil];
-(void)launchTheOtherNotificationMethod:(NSNotification)notification{
[[NSNotificationCenter defaultCenter] postNotificationName:@"anyStringJustMakeItUnique" withObject:self];
}
, :
[[NSNotificationCenter defaultCenter] postNotificationName:@"anotherNotificationName" withObject:nil];
, , - , ViewController1 ViewController2, . ViewController1:
string1 = [myVC2 string2];
, :
[vc1 setString1:[[vc1 myVC2] string2]];
:
[[vc2 myVC1] setString1:[vc2 string2]];