开发者

iOS: How to Create and Maintain an Attribute that Affects Several Different Classes?

开发者 https://www.devze.com 2023-03-22 19:40 出处:网络
My app is constructed with several UIViewControllers based on a UINavigationController. There are some attributes that become relevant in several different classes; for example the device (iPhone/iPad

My app is constructed with several UIViewControllers based on a UINavigationController. There are some attributes that become relevant in several different classes; for example the device (iPhone/iPad) or the device selected language (english/french/Chinese/etc...).

I assume this should be quite trivial, but I actually don't know how to do this (or how this feature is called in XCode): How can I create an a开发者_如何转开发ttribute that will serve all classes?

Should it be located in the AppDelegate file or someplace else?


I think you should create a singleton, so you could share data among your UIViewControllers. Here's a nice tutorial:

http://www.galloway.me.uk/tutorials/singleton-classes/

0

精彩评论

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

关注公众号