Core Data returns a different object instance for the same NSManagedObject each time I fetch it. Why is this?(每次我获取同一个 NSManagedObject 时,Core Data 都会返回一个不同的对象实例.为什么是这样?)
问题描述
我最近注意到,如果我获取一个 ManagedObject ,我可以验证模型中只有一个并且没有保留在我的应用程序中的任何位置,每次获取返回对象时它都是一个不同的实例(使用指向不同内存地址的指针).这是为什么呢?
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.
这篇关于每次我获取同一个 NSManagedObject 时,Core Data 都会返回一个不同的对象实例.为什么是这样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:每次我获取同一个 NSManagedObject 时,Core Data 都会返回一个不同的对象实例.为什么是这样?
基础教程推荐
- iOS4 创建后台定时器 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
