开发者

What is the best method to use data in different view controllers?

I am new to ios development and I am trying to use some methods in different vie开发者_JS百科w controllers in regular intervals of time (using same methods in different view controllers).

Can anyone please tell me what is the best method for this?

Thanks in advance!


I'd suggest using protocol for this. You can never know when you want different method behaviour for different controllers. And you can always implement default behaviour in private category of generic uiviewcontroller.


Maybe you could try to implement this method in a customViewController that would be subclassed by these viewController and than every viewController would have access to these method.

Alternate way would be to implement it on the appDelegate or on a common tabBarController, navigationController (or whatever) and so every viewController would have access to it.

If the time interval has to be the same for every viewControler, you should do only one time interval and iterate on your viewControllers

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜