加载所有视图都希望访问的NSDictionary的最佳位置是什么? [英] What's the best place to load a NSDictionary you want to be accessible to all views?

查看:31
本文介绍了加载所有视图都希望访问的NSDictionary的最佳位置是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有4个不同标签的标签栏应用程序.(4个不同的视图)

I have a tab bar application with 4 different tabs.(4 different views)

当我的应用程序首次启动时,我要做的第一件事就是引入位于plist中的数据.这不是问题.我的问题是,数据以不同的方式显示在每个选项卡中.

When my app first launches, the first thing I need to do is bring in my data which is located in a plist. This isn't a problem. My problem is, the data is displayed in each tab in a different way.

您建议在哪里加载数据的最佳位置?

Where do you suggest the best place to load the data is?

当前,我正在使用第一个viewController的viewDidLoad.但是从这里开始,您认为使数据可用于其他视图的最佳方法是什么?也许使其他3个视图成为第1个视图的委托?

Currently I'm using viewDidLoad of the first viewController. But from here, what do you think the best way to make the data available to the other views is? Perhaps make the other 3 views become a delegate for the 1st view?

任何建议将不胜感激感谢您的帮助.迈克.

Any suggestions would be much appreciated Thanks for you help. Mike.

推荐答案

通过这种方式,我拥有的小数据确实是全局的,因此我在AppDelegate类中创建了一个属性.您的视图控制器都可以使用

The little data I've had that is truly global in this way I've made a property on my AppDelegate class. Your view controllers can all access it with

MyAppDelegate* delegate = [UIApplication sharedApplication].delegate;
id thing = [delegate.myDictionary objectForKey:@"someKey"];

这篇关于加载所有视图都希望访问的NSDictionary的最佳位置是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆