Core Data VS SQL Statement, which one is gd for iphone development?

一个人想着一个人 提交于 2019-12-12 01:34:29

问题


iPhone 3.0 support the Core Data, it seems a great tool for developer. But SQL statement seems it is easier to get start, but core data is easier for maintaining db. But I'm considering the SQL statement, because it seems have better performance. I am consider which one is better for iPhone development, any suggestion?


回答1:


The answer is actually much simpler than either of those blog posts make it appear. The rule is:

  1. If you are developing for any OS X platform;
  2. If you are not accessing a proprietary format; and
  3. If your persistence file does not need to be read on a non OS-X platform

Then you should go with Core Data. It is that simple. Core Data gives you so many features and the ease of use compared to straight SQL makes the choice simple. As far as performance, that is a red herring. Where it counts, Core Data can and does easily out perform custom code accessing a SQLite database. However, performance on Cocoa Touch is actually a secondary concern.

The primary concern is memory. You have a tiny amount of memory in which to work with on Cocoa Touch and your data model can easily blow that out. Core Data solves that issue. It watches how much memory it is using and will drop objects out of memory automatically when it receives a memory warning. All of that fairly complex code you would have to write yourself if you used SQLite directly.

Less time coding your data model means you have more time making your application great.




回答2:


This provides a reasonable list of the pros and cons of either approach: http://maniacdev.com/2009/09/iphone-sqlite-vs-core-data-–-which-to-choose/

The recommendation is to use Core Data as it makes things so much easier in the long term.




回答3:


There is an in-depth explanation of the differences between the 2 here: http://cocoawithlove.com/2010/02/differences-between-core-data-and.html

That's a great read. The 2 approaches are different and both have their pros and cons.



来源:https://stackoverflow.com/questions/2289102/core-data-vs-sql-statement-which-one-is-gd-for-iphone-development

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!