Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个应用程序,它允许自定义属性,例如背景颜色、按钮、文本(即标题)等。在其当前的化身中,viewDidLoad通过调用一个LookAndFeel类在 UI 小部件上设置适当的属性。LookAndFeel读取用户偏好。
viewDidLoad
LookAndFeel
每个视图是否应该调用LookAndFeel,或者应用程序是否应该获取一个属性并在所有视图中使用获取的值?是否可以调用getTitleColor一次,将其保存在应用程序委托中,并在每个视图中使用它?
getTitleColor
这取决于您的getTitleColor方法有多昂贵。如果它很昂贵,它肯定应该被缓存。
(注意:从文件或从文件读取NSUserDefaults可能被认为是昂贵的)
NSUserDefaults