开发者

What is the best way to pass values between to different views?

What is the best way to pass a variabile between 2 different view controllers ? The o开发者_如何学编程nly way that I acually know it's:

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

Thanks


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜