Quote:
Originally Posted by vincefried
Hello guys,
I have an app with a flipsideview for the settings of my app. I want to change an array from another view, when the switch is on. I was getting crazy because of that in another app, months ago, so I tried something else. But now I need to do that, for this app! Hope somebody can help!
Sincerely,
vincefried
|
You need to provide a less vague description if you want help.
In general, if you want one view controller to change values in another view controller's variables, you should make those variables into properties.
So:
Code:
@interface ViewController1: UIViewController
{
NSString* myString;
}
@property (nonatomic, retain) NSString* myString;
@end
Now, in ViewController 2:
Code:
theViewController1.myString = @"A new string value";
You need a way to get a pointer from one view controller to another. A good way to do that is to create properties to all of your view controllers in your app delegate, and then use
Code:
MyAppDelegate* theAppDelegate = (MyAppDelegate*) [[UIApplication sharedApplication] delegate];
...
myViewController1 = theAppDelegate.theViewController1;
myViewController1.myString = @"A new string value";