Core Data在每次获取相同的NSManagedObject时返回不同的对象实例。为什么是这样? [英] Core Data returns a different object instance for the same NSManagedObject each time I fetch it. Why is this?

查看:126
本文介绍了Core Data在每次获取相同的NSManagedObject时返回不同的对象实例。为什么是这样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近注意到,如果我获取一个ManagedObject,我可以验证其中只有一个在模型中,并且不保留在我的应用程序中的任何地方,每次fetch返回对象,它是一个不同的实例指向不同内存地址的指针)。为什么是这样?

I have recently noticed that if I fetch a ManagedObject of which I can verify that there is only one in the model and which is not retained anywhere in my application, every time the fetch returns the object it is a different instance (with a pointer to a different memory adress). Why is this?

推荐答案

如果没有人保留,Core Data可以自由发布。如果你再次请求它,它可能在不同的内存位置。您不能指望它是同一个对象实例。

If no one retains it, Core Data is free to release it. If you ask for it again, it will probably be at a different memory location. You can't count on it being the same object instance.

这篇关于Core Data在每次获取相同的NSManagedObject时返回不同的对象实例。为什么是这样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆