换肤和缓存用户首选项
我有一个应用程序,它允许自定义属性,例如背景颜色、按钮、文本(即标题)等。在其当前版本中,viewDidLoad 通过调用 viewDidLoad
在 UI 小部件上设置适当的属性。代码>LookAndFeel 类。 LookAndFeel
读取用户首选项。
应该每个视图都执行对 LookAndFeel 的调用,还是应用程序应该获取一次属性并在所有视图中使用获取的值?是否可以调用 getTitleColor
一次,将其保存在应用程序委托中,然后在每个视图中使用它?
I have an application which allows customizing attributes such as background color, buttons, text (ie, titles), etc. In its current incarnation, viewDidLoad
set the appropriate property on a UI widget by calling into a LookAndFeel
class. LookAndFeel
reads the user preferences.
Should each view perform a call into LookAndFeel
, or should the Application fetch an attribute once and use the fetched value in all views? Is it OK to call getTitleColor
once, hold it in the app delegate, and use it in every view?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这取决于您的
getTitleColor
方法的成本有多高。如果它很昂贵,那么它肯定应该被缓存。(注意:从文件或从
NSUserDefaults
读取可能会被认为是昂贵的)That depends on how expensive your
getTitleColor
method is. If it's expensive, it should definitely be cached.(Note: reading from a file or from
NSUserDefaults
could be considered expensive)