Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Kansas

macrumors newbie
Original poster
Feb 9, 2009
6
0
I have read google until my eyes bleed!! :)

Is their a standard way to pass a variable from one form to another?

I pop up a form (presentModalViewController) and get two text fields that I want to return to the form that called the modalview.

There has to be an easy way to do this that is OOP!

I read some stuff about a singelton class but it seems not standard enough.

Thanks for any help!!
 

Kansas

macrumors newbie
Original poster
Feb 9, 2009
6
0
I ended up putting a NSString in my AreYou_AppDelegate and then using this code to read it and set it. Hopes this helps someone!

//readit
AreYou_AppDelegate *mainDelegate = (AreYou_AppDelegate *)[[UIApplication sharedApplication] delegate];
StatusMessage.text = mainDelegate.passrating;

//setit
AreYou_AppDelegate *mainDelegate = (AreYou_AppDelegate *)[[UIApplication sharedApplication] delegate];
mainDelegate.passrating = password.text;
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
Basically if you're using the app delegate like this you're probably doing it wrong. In your case you probably just need use properties properly to pass variables between the view controllers.
 

ghayenga

macrumors regular
Jun 18, 2008
190
0
Basically if you're using the app delegate like this you're probably doing it wrong. In your case you probably just need use properties properly to pass variables between the view controllers.

You are correct, but what I think he's looking for is that after you've created a property then from your modal view controller you can just say:

self.parentViewController.propertyName = myTextField.text;
 

firewood

macrumors G3
Jul 29, 2003
8,141
1,384
Silicon Valley
With the MVC paradigm, I think you actually should pass app information to a model controller to go from and to each view controller, instead of directly between view controllers. This would allow you to modify or completely change each view or view controller independently of the other; and store, modify, or log the model information, also independent of any view.

imho...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.