No consensus on passing fields between forms?

Discussion in 'iOS Programming' started by Kansas, Feb 13, 2009.

  1. Kansas macrumors newbie

    Joined:
    Feb 9, 2009
    #1
    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!!
     
  2. Kansas thread starter macrumors newbie

    Joined:
    Feb 9, 2009
    #2
    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;
     
  3. caveman_uk Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #3
    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.
     
  4. ghayenga macrumors regular

    Joined:
    Jun 18, 2008
    #4
    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;
     
  5. firewood macrumors 604

    Joined:
    Jul 29, 2003
    Location:
    Silicon Valley
    #5
    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...
     
  6. caveman_uk Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #6
    In an app I'm working on I do both. I use singleton model classes but I also use properties to pass 'trivial' info between view controllers.
     

Share This Page