NSUserDefaults and saving size

谁说胖子不能爱 提交于 2019-12-11 05:42:29

问题


I have an app that tracks a user as they drive along. It uses CLLocationManager and each time the didUpdateToLocation is called I save the CLLocation point.

A trip of around 25 miles yields somewhere in the neighborhood of 1200 points.

As of now I save this array of points to the user defaults for testing. Should I look at CoreData to properly save this information? Or possible just write everything out to a file?

My concern is that can NSUserDefaults "max out"? I could potentially have hundreds of saved arrays, each with thousands of CLLocation points.

Any suggestions would be very much appreciated.


回答1:


regardless of the size of users default, it is not meant for this purpose. As the name implies it should be used for saving flags and variables to customize or save session specifics of the user. Even though core data does offer an elegant solution for this and is the most efficient one. If you don't want to deal with this you would have to create your own file and save it there. Which is also pretty simple. However i suggest coredata if you plan on expanding the possibilities, like multiple user, different runs, lots of attributes etc etc since it is a real database like approach.

http://www.raywenderlich.com/934/core-data-on-ios-5-tutorial-getting-started

Edit: there's no limit to user's default size. Still if you go through apples documentation you will see how it is NOT meant for the purpose you describe.

http://www.iphonedevsdk.com/forum/iphone-sdk-development/38091-size-limitations-with-nsuserdefaults.html



来源:https://stackoverflow.com/questions/11661119/nsuserdefaults-and-saving-size

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