Frage

I have Entity UserProfile with attribute uId. I receive users from web and add they in core data. I want that if there is a user with his id in my base - he will be replaced. I use tip https://github.com/magicalpanda/MagicalRecord/wiki/General-tips But How can I set that I want to use primary key?

War es hilfreich?

Lösung

You need to first do a fetch request and check if there is a UserProfile with that uId.

If there is, then just update that UserProfile and save.

If not, then create a new UserProfile and save.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top