View Full Version : Getting Data Back from an NSPopover

Aug 4, 2012, 03:30 PM
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?


Aug 5, 2012, 05:41 AM
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.

Aug 5, 2012, 02:47 PM
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.

Aug 6, 2012, 03:33 AM
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.