简体   繁体   中英

Core data unique entity attribute

I have got entity with NSNumber like id. Then I receive web response with userProfile I create and save its entity with id. If I receive 2 the same userProfiles I have 2 entities in my base. How can I confine my base that it has only one entity with same user id?

Instead of always creating a new user profile when you receive data, use a fetch request to search for an existing profile. If you find one, update it and save. If you don't, then create a new one and save.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM