1

我在我的应用程序中实现了一个 IM 消息模块,但是将消息保留为历史存在一个问题。在我的模型中,我使用服务推送所有消息,而新消息带有套接字。

我认为在设备上保存消息历史记录是节省服务带宽的更好方法。我正在考虑NSUserDefaults用于保存数据,但我真的不知道性能问题。有没有更好的方法来保持设备中的大行?

4

1 回答 1

1

If there is small data then use NSUserDefaults.

But if data is in large amount use CoreData or Sqlite. It is safe and secure.

Apple has made CoreDate more good in terms of performance.

Sqlite3 is more useful for keeping large database and to access to the database elements. You can sort the items of sqlite3 database, you can search very fast for item in Sqlite3 database.

You're not going to see a speed difference, but it's still best to pick the correct mechanism for what you're doing. If it's just preferences then use NSUserDefaults, otherwise I would serialize your objects to a plist. If you're new to Cocoa I would avoid Core Data and even sqlite at first, to give yourself a chance to learn the basics first.

于 2013-08-15T14:21:06.157 回答