在iPhone上存储应用程序数据的最佳方法是什么?

时间:2022-12-08 12:57:28

There are various ways for iPhone applications to save data (for example: NSUserDefault, XML, document, SQLite, etc.).

iPhone应用程序有多种方法可以保存数据(例如:NSUserDefault,XML,document,SQLite等)。

Our company always uses NSUserDefault to save data. However, I don't think NSUserDefault is very good because in my experience, it has been slow.

我们公司总是使用NSUserDefault来保存数据。但是,我不认为NSUserDefault非常好,因为根据我的经验,它一直很慢。

I am curious how you store data for your applications and when you recommend using each of the different methods. Please share your experiences that will help me to understand the advantages and disadvantages of these different storage types and develop a more efficient application for my users.

我很好奇您如何为应用程序存储数据以及何时建议使用每种不同的方法。请分享您的经验,这将有助于我了解这些不同存储类型的优缺点,并为我的用户开发更高效的应用程序。

4 个解决方案

#1


4  

You can store small data in NSUserDefaults but when you have large database then you need sqlite or coredata for storing the database. use of coredatabase is good for big database this is provided by apple and it is to efficient in accessing database.

您可以在NSUserDefaults中存储小数据,但是当您拥有大型数据库时,您需要sqlite或coredata来存储数据库。使用coredatabase对大数据库有好处,这是由apple提供的,它有效地访问数据库。

NSUserDefaults or document directory is used for small database(suppose need to store user name for single user or some other info).

NSUserDefaults或文档目录用于小型数据库(假设需要为单个用户或其他信息存储用户名)。

#2


2  

You just need to know about sql queries to store data in a SQLite3 Database or You can use Core Data for back end storage. Core Data is one of the best options to use for storing data.

您只需要了解用于在SQLite3数据库中存储数据的SQL查询,或者您可以使用Core Data进行后端存储。核心数据是用于存储数据的最佳选择之一。

NSUserDefault should be used for storing small information.

NSUserDefault应该用于存储小信息。

#3


1  

You can use NSUserDefaults for storing any small data which you want to persist when your application closes. This you can use to store login details but yes if it is be secured, use keychain. You can definely use NSUserDefaults for storing setting options.

您可以使用NSUserDefaults存储应用程序关闭时要保留的任何小数据。这可以用来存储登录详细信息,但是如果它是安全的,则使用钥匙串。您可以定义使用NSUserDefaults来存储设置选项。

SQLite database is any easy way to store large data. Core Data is best option. but you can use SQLite if your application data is not too large. SQlite Database can also be used to store BLOB data e.g. to store pdf file bytes downloaded from server and whenever you want to use it, just write those bytes to pdf file. This will also keep data security since BLOB data in SQLite cannot be viewed.

SQLite数据库是存储大数据的简便方法。核心数据是最佳选择。但如果您的应用程序数据不是太大,您可以使用SQLite。 SQlite数据库也可用于存储BLOB数据,例如存储从服务器下载的pdf文件字节,无论何时使用它,只需将这些字节写入pdf文件即可。这也将保持数据安全,因为无法查看SQLite中的BLOB数据。

#4


-1  

Its good to use coreData for large data storage in the IPhone Memory space. ITs a wrapper on top of the database which helps us to store in the form of objects..... U can find many examples on this...

在iPhone内存空间中使用coreData进行大数据存储很方便。它是数据库顶部的包装器,它可以帮助我们以对象的形式存储......你可以在这个上找到很多例子......

#1


4  

You can store small data in NSUserDefaults but when you have large database then you need sqlite or coredata for storing the database. use of coredatabase is good for big database this is provided by apple and it is to efficient in accessing database.

您可以在NSUserDefaults中存储小数据,但是当您拥有大型数据库时,您需要sqlite或coredata来存储数据库。使用coredatabase对大数据库有好处,这是由apple提供的,它有效地访问数据库。

NSUserDefaults or document directory is used for small database(suppose need to store user name for single user or some other info).

NSUserDefaults或文档目录用于小型数据库(假设需要为单个用户或其他信息存储用户名)。

#2


2  

You just need to know about sql queries to store data in a SQLite3 Database or You can use Core Data for back end storage. Core Data is one of the best options to use for storing data.

您只需要了解用于在SQLite3数据库中存储数据的SQL查询,或者您可以使用Core Data进行后端存储。核心数据是用于存储数据的最佳选择之一。

NSUserDefault should be used for storing small information.

NSUserDefault应该用于存储小信息。

#3


1  

You can use NSUserDefaults for storing any small data which you want to persist when your application closes. This you can use to store login details but yes if it is be secured, use keychain. You can definely use NSUserDefaults for storing setting options.

您可以使用NSUserDefaults存储应用程序关闭时要保留的任何小数据。这可以用来存储登录详细信息,但是如果它是安全的,则使用钥匙串。您可以定义使用NSUserDefaults来存储设置选项。

SQLite database is any easy way to store large data. Core Data is best option. but you can use SQLite if your application data is not too large. SQlite Database can also be used to store BLOB data e.g. to store pdf file bytes downloaded from server and whenever you want to use it, just write those bytes to pdf file. This will also keep data security since BLOB data in SQLite cannot be viewed.

SQLite数据库是存储大数据的简便方法。核心数据是最佳选择。但如果您的应用程序数据不是太大,您可以使用SQLite。 SQlite数据库也可用于存储BLOB数据,例如存储从服务器下载的pdf文件字节,无论何时使用它,只需将这些字节写入pdf文件即可。这也将保持数据安全,因为无法查看SQLite中的BLOB数据。

#4


-1  

Its good to use coreData for large data storage in the IPhone Memory space. ITs a wrapper on top of the database which helps us to store in the form of objects..... U can find many examples on this...

在iPhone内存空间中使用coreData进行大数据存储很方便。它是数据库顶部的包装器,它可以帮助我们以对象的形式存储......你可以在这个上找到很多例子......