Comparing two NSManagedObjects

后端 未结 3 1456
眼角桃花
眼角桃花 2021-02-07 02:02

I have some code that loops through an array of NSManagedObjects and stops when it finds a certain record that is stored in an instance variable. The only way I can manage to se

3条回答
  •  深忆病人
    2021-02-07 02:58

    The commenter is correct, isEqualTo: will not work in this case since they are different instances of NSManagedObjectID.

    The way you are doing this is actually the best way, the objectID is CoreData's unique identifier for a given managed object, it's the only way to tell if two instances of NSManagedObject point to the same record in the persistent store.

提交回复
热议问题