使用iOS应用程序中的数据(可选择什么?NSData,CoreData,sqlite,PList,NSUserDefaults) [英] Working with data in iOS Apps (What to choose? NSData, CoreData, sqlite, PList, NSUserDefaults)

查看:1117
本文介绍了使用iOS应用程序中的数据(可选择什么?NSData,CoreData,sqlite,PList,NSUserDefaults)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开发一个iPhone应用程序(时间跟踪,ToDoList等)我从来不知道什么是处理数据的最佳方式。一旦我使用plist,下一次sqlite或CoreData。



如何决定什么是最适合你的项目?
(只谈数据管理)



例如,如果你想开发:



    $
  • 照片应用程序> sqlite?

  • li>
  • EMail Client>?



对于初学者,
(我知道这取决于应用程序,你喜欢用
做什么,但任何想法都会有所帮助)





感谢您的帮助,
Marc




    您可以使用这些经验法则来决定哪些存储模型适用于您的应用程序。 li>如果数据完全适合内存并且相对无结构,请使用plist
  • 如果数据完全适合内存并且具有树状结构,请使用XML

  • 如果数据不适合内存并且具有图形结构,并且应用程序不需要非凡的查询功能,请使用Core Data

  • 如果数据不合适或者应用程序受益于关系数据库提供的强大的查询功能,请使用sqlite

  • 如果数据必须是机密的(例如密码),请使用钥匙串



请注意,这些选择通常重叠,因为多个存储模型将适合相同的应用程序。



有一个关于sqlite与核心数据的非常好的问题 Stack Overflow,你可能想阅读这个问题的答案。


when I develop an iPhone App (Time Tracker, ToDoList etc) I never know whats the best way to deal with the data. Once I used a plist, next time sqlite or CoreData.

How do you decide whats the best for your project? (Only talking about data management)

For Example if you want to develop:

  • Time Tracker App > Is PList your choice?
  • RSS Reader App > CoreData?
  • Photo App > sqlite?
  • EMail Client > ?

For a beginner can you point me roughly to proper directions? (I know it depends a lot on the App and what you like to do with it but any thought will help)

I'm far away from developing complicated apps, they are still pretty simple.

Thanks for help, Marc

解决方案

You can use these rules of thumb to decide what storage model will work for your app.

  • If the data fits in memory entirely and is relatively unstructured, use plist
  • If the data fits in memory entirely and has tree-like structure, use XML
  • If the data does not fit in memory and has a structure of a graph, and the app does not need extraordinary query capabilities, use Core Data
  • If the data does not fit in memory, has a complex structure, or the app benefits from powerful query capabilities provided by relational databases, use sqlite
  • If the data must be secret (e.g. a password), use keychain.

Note that these choices often overlap, because multiple storage models will fit the same app. Your final decision depends on your personal preferences - you pick a technology that you understand better.

There was a very good question about sqlite vs. Core Data on Stack Overflow, you may want to read through the answers to that question.

这篇关于使用iOS应用程序中的数据(可选择什么?NSData,CoreData,sqlite,PList,NSUserDefaults)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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