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 都会返回一个不同的对象实例.为什么是这样?
基础教程推荐
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
