决定使用Core Data或NSUserDefaults [英] Deciding to use Core Data or NSUserDefaults
问题描述
我在应用程式上有一项功能,允许使用者邀请他们的朋友(透过Facebook或朋友在他们的通讯录)。大多数人将< 5K的朋友有一些人有更多(也许最多像10K的朋友?)。
我想跟踪他们邀请的朋友,以便他们不要再邀请他们。要完成这个,我在 NSUserDefaults
中保存朋友的dict来存储这些信息。我想知道如果 NSUserDefaults
将足够了这一点,或者如果我需要使用 Core Data
。
此外,我计划添加一个功能,允许他们邀请朋友参加特定活动。 (在我们的应用程序有很多事件。)如果我想跟踪哪些朋友被邀请到哪个事件,我应该使用核心数据
然后? NSUserDefaults
足够了吗? (我假设它不会)。最后,应该
NSUserDefaults
实际上用于存储小数据,如设置,首选项和个人值。
您应该使用Core Data来存储大量的元素列表。至于你最后一个问题,没有什么阻止你使用Core Data和后端来存储你的数据。事实上,有框架在那里有助于这个。查看 RestKit 。
I have a feature on my app that allows users to invite their friends (via facebook, or friends in their address book). Most people will have < 5K friends with some people having more (maybe a max of like 10K friends?).
I want to keep track of the friends they have invited so they do not re-invite them. To accomplish this I am saving a dict of friends in NSUserDefaults
to store this information. I am wondering if NSUserDefaults
will suffice for this, or if I need to use Core Data
.
Also, I am planning on adding a feature to allow them to invite friends to a particular event. (there are many events on our app.) If I want to keep track of which friends have been invited to which event, should I be using Core Data
then? Will NSUserDefaults
suffice for that? (I am assuming it won't). And lastly, should Core Data
be used for that or should that be saved server side?
NSUserDefaults
is really meant for storing small pieces of data such as settings, preferences, and individual values.
You should use Core Data to store a large list of elements. As far your last question, there is nothing preventing you from using both Core Data and a backend to store your data. In fact, there are frameworks out there to facilitate exactly this. Take a look at RestKit.
这篇关于决定使用Core Data或NSUserDefaults的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!