tags:

views:

125

answers:

2

What is the best way to pass a variabile between 2 different view controllers ? The only way that I acually know it's:

app = (yourApp_comAppDelegate *) [[UIApplication sharedApplication] delegate];

Thanks

+2  A: 

View should not hold values. your values should be encapsulated in model objects, and your views should be rendering the current state of those models.

Brad Smith
i understood this part of the application design, my question it's about the techniques to pass data between view :)
Cesar
Brad's right though. Use Core Data, and then your Views can directly query Core Data for model objects.
bpapa
A: 

You probably should not pass data between views, rather pass data between their viewcontrollers, though they should not be modifying model objects the only thing they might report are touches or a change to their state due to user interactions, if they are Both in the same view controller then pass messages to the view controller and have it take the approrpiate action with the other view, it's not good design to have views talk or know about each other it makes them less reusable.

Now for passing messages from the views to your view controller u should have a look at protocols , have the view define the protocol and the view controller implement it , any object can implement it really and have the view report to it...Here is a link to read about protocols
http://developer.apple.com/mac/library/documentation/cocoa/conceptual/ObjectiveC/Articles/ocProtocols.html Hope that helps

Daniel