开发者

Slider value available between different cocoa classes

开发者 https://www.devze.com 2022-12-27 08:02 出处:网络
I am playing around with an iPhone 开发者_C百科app, and need to accomplish something that I am sure is very basic:

I am playing around with an iPhone 开发者_C百科app, and need to accomplish something that I am sure is very basic:

I have a slider that is implemented in a Controller.m class. However, I need its value must be available in a different class, MainView.m class where I have defined an equation that depends on the value of the slider. How can I do it??

Thanks,

Miguel Bayona


This comes down to application design. Your slider belongs, rightly, to a ViewController object. But its value is a model property. So you need to separate the two, and work out how to pass the value from the controller into the model, and provide access to that value for other classes.

The basic knowledge you need is an understanding of MVC (Model-View-Controller). And the technology you need to pass values around is an understanding of Objective-C properties and, in general, accessor methods.

In practical terms, you need a connection from your slider to your view controller, and from your view controller into other controllers or views.

It is relatively unlikely that a view object would be handling an equation (although entirely possible). That is behaviour more suitable for a model object.

0

精彩评论

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

关注公众号