Georgi Georgi - 3 months ago 12x
iOS Question

Core Data vs NSUserDefaults for logged in user data

I have an app where I already use Core Data to store a big amount of shops, which a user can view once logged in. I am currently implementing the login part of the app and I looked through many related questions. Most of them suggest using

for storing non sensitive user data. I am planning to store things like first name, last name, email, profile picture and maybe address. The list may grow in future. My question is it a valid option to create a User
in my Core Data Model in order to store a single user object or it will be a bad practice and I should just make it with
? I am tempted to use Core Data since I already have everything set up and it would not add extra complexity to the implementation.


I was in a very similar situation that you were in while developing a recent app. I found that NSUserDefaults was a more appropriate solution for storing user information, since that's what it's explicitly meant to be used for. As the Apple documentation on it says, 'The NSUserDefaults class provides a programmatic interface for interacting with the defaults system. The defaults system allows an application to customize its behavior to match a user’s preferences.'

From my experience, using NSUserDefaults to store user info rather than Core Data meant having a lot less code. Additionally, you don't have the overhead of having to access the Core Data store every time your user logs into your app).

For reference, I used this and this when I was learning where to use NSUserDefaults.