How to return data from a pop up view to the calling class

OleSetnes used Ask the Experts™
Can anyone suggest a smart way of returning data from a pop up view to the calling class. I can think of a number of rather complicated methods with protocols or pointers to structures in the calling class.

The problem is generic. I have a view and I need to prompt for some user input. Therefore I load another view that prompts for the data. After the user has entered the data and clicked OK the data has to be passed back to the calling class.

What is the smartest way to do that?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I am not sure there is a "right answer" to your question.  

The one I recently used was I passed a reference to my calling class to the popup view class.  

My calling class had properties for the data that is got from the popup view.

So when the user gave some input on the popup view its class could simply add this to the property of the calling class.
Thank you for the answer. I was hoping for a for a solution where I didn't have to pass a pointer from the calling class as it would create a direct dependency between the calling class and the dialog prompting for the data.

In the mean time I created a solution where I defined a protocol in the in the prompting dialog. The protocol defines an update method that passes the data that needs to be returned. The calling class implements the protocol and when creating the prompting dialog it passes the update method as a selector.

It works but it is a bit complicated.
As I said there is not a "right answer".

I prefer passing things around but I am not a professional programmer and I think the "professional way" is with protocols.  

It is complicated but if you get used to protocols they could be used more often.
Whilst i do not  intend to object as you have used another method, I have answered your question and answered it correctly.

Either with or without my help you have been able to decide that another method is possible which I also told you is possible and evaluate which method you will now use.

If you want to look at it strictly I have at least answered your question to 50% and you can also split points on EE.


The best I could come up with.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial