Вопрос

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?

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top