Getting Data Back from an NSPopover

Discussion in 'iOS Programming' started by larswik, Aug 4, 2012.

  1. larswik, Aug 4, 2012
    Last edited: Aug 4, 2012

    macrumors 68000

    Joined:
    Sep 8, 2006
    #1
    EDIT: Opps. I posted this in the Mac section and not the IOS section. sorry

    I created my first popover for an iPad app. I need to return a value back from it when it is pressed. But in making it I can see that I am basically creating a new UIViewController class and it is easy to push information to it while you are.

    So getting the info back to my first view controller I would use NSUserDefaults or a Singleton which I have never experimented with yet as a global variable?

    I am wondering what is the best way if anyone can recommend something for returning data to the first ViewController?

    Thanks.
     
  2. macrumors 68030

    MattInOz

    Joined:
    Jan 19, 2006
    Location:
    Sydney
    #2
    What about a delegate protocol on the view controller in the popover.
    If the base view controller implements the protocol then sets itself as delegate the your picker so your picker can message back results.

    Have a look at UIPickerView as an example.
     
  3. thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #3
    I have not looked at that. But I will. I looked at something like that a little but looked kind of confusing. I will check out the picker you recommended. I can always go back to using plists for data transfer but wanted to learn something new.

    Thanks for the help.
     
  4. thread starter macrumors 68000

    Joined:
    Sep 8, 2006
    #4
    I ended up passing this data with a singleton. I learned how to create and use them today, a very handy tool. I used the popoverControllerDidDismissPopover: in the first view controller to fetch the data from the singleton and assign it to the UILable in the first viewController.
     

Share This Page