0

I'm writing an application which uses core data, and I use it to store a reasonable amount of user generated data.

However, the app also has a few settings ... such as the users name, age.

I'm wondering if it is better practice to store setting information in CoreData, or to simply store this information in UserDefaults?

jdawg
  • 508
  • 2
  • 5
  • 18

4 Answers4

1

answer acording to title: no

(added: especially not large amounts of binary data)

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135
0

This is really more a question for Programmers Stack Exchange, but I give it a quick go over.

Core Data is powerful, but that power comes at a cost. It adds complexity and indirection.

I think it good to think of all your model objects separately. Figure out what makes the most sense for that object. This is not to say let chaos rule, patterns make code easier to understand. I think it's not good to shoehorn something into an existing pattern, because you want everything in your app to fit the pattern.

All that said. Unless your app is storing a list of users, I think it's better to use the simpler approach of NSUserDefaults.

Jeffery Thomas
  • 42,202
  • 8
  • 92
  • 117
0

Core Data is a big thing, not really simple. I would rather you to think about your data model first. If its "big" enough and you think about to expand it maybe in the future i would recommend you to use core data.

Now to my personal opinion:

I'm not really a fan of Core Data. I use mostly a SQlite-Database. If you need alot more and you are a starter checkout parse.com. Its a complete backend-service in verious languages. Check it out..

SaifDeen
  • 862
  • 2
  • 16
  • 33
  • This doesn't make sense at all. You can't compare Core Data vs SQLite. Core Data is an Objective-C Api. From the docs: `Core Data provides an infrastructure for change management and for saving objects to and retrieving them from storage. It can use SQLite as one of its persistent store types.` – Desdenova Mar 11 '14 at 14:37
  • I didnt compared them. I just said I use SQLite rather than Core Data because its way more practical. And as you said Core Data is based on SQLite and FMDB is a really nice wrapper. So yes I just use SQLite rather than Core Data. – SaifDeen Mar 11 '14 at 14:50
0

If you are saving credentials or some other protected data then this is the best practice:

iOS: How to store username/password within an app?

For temp data and most of other flat data use UserDefaults...

Use CoreData as more structural data storage, when you have lots of records or linked records, for more complex data structures in general...

Community
  • 1
  • 1
AntonijoDev
  • 1,317
  • 14
  • 29