Handling duplicate entries in Core Data

前端 未结 6 490
野的像风
野的像风 2021-02-04 10:28

I have an app that allows users to save favorites. I am using Core Data to store the favorites as managed objects. I have written some code to prevent the possibility of storing

6条回答
  •  北恋
    北恋 (楼主)
    2021-02-04 10:35

    Just an update since iOS 9.0 you can do it easily with "unique constraints" in the model. But pay attention if your store already contains duplicate core data will fail any auto migration when the app shipped.

    See here for example - core data unique constraints

提交回复
热议问题