Core Data 数据出现Fault
来源:互联网 发布:印度理工学院 知乎 编辑:程序博客网 时间:2024/06/06 02:47
I am mapping Json Data from Server using Restkit and I am Displaying those data by fetching from db. There is a refresh button in my view which performs the above operation again.
Scenario: I have two tables Key & Profile which has one-one relationship. I am fetching data from DB using follwing code
NSFetchRequest *fetchRequest = [Key fetchRequest];[fetchRequest setRelationshipKeyPathsForPrefetching:[NSArray arrayWithObject:@"Profile"]];[fetchRequest setIncludesSubentities:YES];NSArray *sortedObjects = [Key executeFetchRequest:fetchRequest];
Above array returns all object in DB. but when i check that using breakpoint, i got some core data fault which was the reason for not showing all the data.
//All data in sortedObjects are like this.
<Key: 0x889f2f0> (entity: Key; id: 0x889e400 <x-coredata://981A476D-55AC-4CB4-BBD8-E0285E522412/Key/p1489> ; data: <fault>)
Any idea
This might be a misunderstanding about what a 'fault' is.
As described in Apple's documentation:
Faulting is a mechanism Core Data employs to reduce your application’s memory usage.
and
A fault is a placeholder object that represents a managed object that has not yet been fully realized, or a collection object that represents a relationship:
So, if you see the word 'fault' in logs when you're working with Core Data, it doesn't mean that an error has occurred. What unexpected behaviour are you seeing in your app?
You haven't actually described a problem. A Core Data fault isn't an error-- it's more like a page fault in a file system. It just means that the data hasn't been read yet. What you're describing is completely normal and expected. If you access any of the attributes of the returned objects, the fault will be automatically filled and you'll see the results. So if your Key
entity has an attribute called name
, you can still look up the value(s) for name
and even log them if you want.
You could force the faults to be filled by adding this before executing the fetch request:
[fetchRequest setReturnsObjectsAsFaults:NO];
It's not necessary though and, depending on what attributes you have and how many objects you fetch, could use a lot more memory than is really needed.
- Core Data 数据出现Fault
- Core Data could not fulfill a fault
- IOS Core Data之数据保存---顺序出现错误
- Core Data 数据验证
- 常量字符串出现的segmentation fault(core dumped)
- Core Data的数据迁移
- Core Data数据持久化
- iOS 数据存储 - Core Data
- iOS数据 - Core Data使用
- iOS数据存储--Core Data
- Core Data容易出现的错误
- Segmentation fault (core dumped)
- Segmentation fault (core dumped)
- Segmentation fault (core dumped)
- Segmentation fault (core dumped)
- Segmentation fault (core dumped)
- Segmentation fault(Core Dump)
- segmentation fault core dump
- iOS - webView检测电话和邮箱问题
- C++ Config 配置文件类
- perl读写文件
- 理解offsetparent
- Windows下如何使用命令行来配置iSCSI连接
- Core Data 数据出现Fault
- #pragma comment( lib , "libTest.lib" )的意思
- 螺旋队列
- 常用linux命令
- Android系统添加新的字体
- 我也学别人模拟一下PHP多线程
- spring使用编程式事务
- 暑假开始
- 螺旋队列问题