简体   繁体   English

NSUserDefault持久性的优缺点?

[英]NSUserDefault persisance advantages and disadvantages?

I am new to NSUserDefault 我是NSUserDefault的新手

1) what kind of data can we store in NSUserDefault and cant we store in NSUserDefault? 1)我们可以在NSUserDefault中存储什么样的数据,而不能在NSUserDefault中存储什么数据?

2) can We achieve RDMS concepts in NSUserDefault like SQlite? 2)我们可以像SQlite一样在NSUserDefault中实现RDMS概念吗?

3) where is it stored and can we acces it directly like Sqlite? 3)它存储在哪里,我们可以像Sqlite一样直接访问它吗?

1) what kind of data can we store in NSUserDefault and cant we store in NSUserDefault? 1)我们可以在NSUserDefault中存储什么样的数据,而不能在NSUserDefault中存储什么数据?

You can save app status, game scores, preference etc. Please don't store sensitive information like password, credit card information etc in NSUserDefaults. 您可以保存应用程序状态,游戏分数,首选项等。请不要在NSUserDefaults中存储敏感信息,例如密码,信用卡信息等。 For that use Keychain services . 为此,请使用钥匙串服务

2) can We achieve RDMS concepts in NSUserDefault like SQlite? 2)我们可以像SQlite一样在NSUserDefault中实现RDMS概念吗?

NSUserDefault is entirely different from SQLite, or any other database. NSUserDefault与SQLite或任何其他数据库完全不同。 It is just used to store lightweight objects like app preferences and states. 它仅用于存储轻型对象,例如应用程序首选项和状态。 It is not designed for heavy data storage at all. 它根本不是为大量数据存储而设计的。

3)where is it stored and can we acces it directly like Sqlite? 3)它存储在哪里,我们可以像Sqlite一样直接访问它吗?

NSUserDefault values are stored as plist files under Library->Preference in your app bundle. NSUserDefault值存储为应用程序包中“库”->“首选项”下的plist文件。 You can access it like any plist files 您可以像访问任何plist文件一样访问它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM