I use nsfetchedresultscontroller to maintain entity “Product”.
But i set a predicate "forUser==%@", currentUser", User is another entity.
Though i can load in the currentUser at runtime, but I wanted to save the “CurrentUser” somewhere in nsuserdefaults, in SQL i’d save the primaryKey of that User there,
On appDidFinishLaunching i could grab that and get the entity.
Im not sure what exactly i should save when it comes to an Entity in the NSUserDefaults.
I don’t want to add an extra attribute of
“last accessed”
to the user, cuz at a time, there is only One current user, and it makes sense to just same some kinda ID. I can save the lastName or firstName, but was thinking about a better way to do it, like some kinda integerID.
Saving NSManagedObjectID URI was also an option, but that would change incase of any migration or core data graph changes, and break the app on update.
please help me understand this in core data.
You have to add an id given the usecase you mentioned. You wanted to store it in NsUserDefaults right?