将 JSON 保存到 NSUserDefaults 并从那里填充ableview 是真的吗?
在我的应用程序中,我从服务器获取一些数据并将其保存到 NSUserDefaults 中,并希望使用该数据中的一些元素填充 TableView(我的 tableview 与我发送 GET 并带来数据的类是不同的类)。但当我用谷歌搜索时,我无法确定我做得是否正确。正如我从谷歌搜索(以及从这个网站)看到的那样,这不是最好的方法,但我不能确定..所以,有人可以给我一个关于“用一些结果填充不同类中的表格视图”的想法吗?在不同的类中创建的 JSON 响应”?
注意-1:如果您的建议是 .plist,请提供一些有关如何操作的示例代码。
Note-2:我使用ios 5,但在我的项目中没有使用ARC
in my app i fetch some data from a server and save it into NSUserDefaults and want to populate the TableView with some elements from that data(my tableview is a different class to my class in which i send the GET and bring data). But as i googled i can't be sure if i'm doing right. As i see from googling(and from this site) this is not the best way but i can't be sure.. So, can some one give me an idea about the way to "populate tableview in a different class with some results of JSON response which created in a different class"?
Note-1: If your suggestion is .plist please give some samplecode about how to do.
Note-2: I use ios 5 but don't use ARC in my project
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了做这样的事情,我建议您研究 Core Data 来存储数据,并将其提取到您需要的任何类中。还建议使用开源 JSON 库:
http://stig.github.com/json-framework/
为了解析 JSON,您将其作为有效对象存储到核心数据模型中。如果您在我开始使用本教程之前没有使用过 Core Data,那么它真的很棒:
http://www.raywenderlich.com/934/core-data-tutorial-getting-started
在开始之前,值得先浏览一下整个过程。我知道如果您以前没有使用过新东西,那么学习新东西会很痛苦,但这绝对是这样做的方法。当您知道如何使用时,Core Data 就会变得如此强大、方便且简单!
希望这对您有一些帮助:)
For doing something like this I would recommend looking into Core Data for storing you data, and pulling it out in whichever class you need it. Would also suggest using the open source JSON library:
http://stig.github.com/json-framework/
in order to parse the JSON that you have an store it into you Core Data model as valid objects. If you have not used Core Data before I used this tutorial when I started, it was really good:
http://www.raywenderlich.com/934/core-data-tutorial-getting-started
It's worth going through the whole thing before you start. I know its a pain having to learn something new if you haven't used it before, but this id definitely the way to be doing it. And Core Data is so powerful, handy and simple when you know how to use!
Hope this is of some help to you :)