Core Data: avoiding retain cycles in to-many relationships

后端 未结 3 916
感情败类
感情败类 2021-02-07 12:28

I\'m still learning my way through iOS development and working with Core Data and have just come across retain cycles.

It is my understanding from reading the Core Data

3条回答
  •  生来不讨喜
    2021-02-07 13:05

    As you can check at Breaking Relationship Retain Cycles, the retain cycles are necessary to prevent deallocation of unwanted objects. It means that you keep the the object retained while you are using it.

    The refreshObject:mergeChanges should be used if you are done with that object and you want to turn it into fault, to dispose memory if possible. It won't necessarily release the object in the other end of the relationship, it will only set a flag to core data that the object can be turned into fault if necessary.

提交回复
热议问题