开发者

NSUser Defaults vs. App Delegate for App Settings

开发者 https://www.devze.com 2023-04-06 05:09 出处:网络
I currently have my app settings stored in an Entity called Settings. Each of my setting开发者_如何学Gos is an attribute. I have one Settings object which I load in my app delegate, and I access it th

I currently have my app settings stored in an Entity called Settings. Each of my setting开发者_如何学Gos is an attribute. I have one Settings object which I load in my app delegate, and I access it through the delegate throughout the project. I am thinking of moving the settings to NSUser defaults. I would probably not need the Settings bundle since I have everything setup in the app. Besides the use of the settings bundle, I was wondering if anyone can tell me what are the benefits of using NSUserDefaults over my current method? Is there any way my choice can affect/improve app performance?


If there are a substantial number of items to be saved then archiving or a plist such as you currently have may well be best.

One advantage of NSUserDefaults is that specific items can be accessed and saved from any method individually. NSUserDefaults also supports several non object types.

Typically if I need to save essentially most of a classes state I will use archiving.

There is no reason not to use a combination, choose the method of persistence of each item individually.

Generally there will not be a large performance difference.

For substantial data choose Core Data.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号