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的更多相关文章

  1. Core Data(数据持久化)

    Core Data可能是OS X和iOS中最容易被误解的框架之一了.为了帮助大家理解,我们将快速研究Core Data,来看一下它是关于什么的.为了正确使用Core Data, 有必要理解其概念.几乎 ...

  2. Core Data数据持久性存储基础教程-备用

    摘要 就像我一直说的,Core Data是iOS编程,乃至Mac编程中使用持久性数据存储的最佳方式,本质上来说,Core Data使用的就是SQLite,但是通过一系列特性避免了使用SQL的一些列的麻 ...

  3. iOS教程:Core Data数据持久性存储基础教程

    目录[-] 创建Core Data工程 创建数据模型 测试我们的数据模型 来看看SQL语句的真面目 自动生成的模型文件 创建一个表视图 之后看些什么? 就像我一直说的,Core Data是iOS编程, ...

  4. Core Data数据操作

    1.建立学生实体,插入100条数据 2.按条件查询学生数据 3.统计学生信息 4.修改学生信息 5.删除学生数据 import UIKit import CoreData class ViewCont ...

  5. iOS开发中的4种数据持久化方式【二、数据库 SQLite3、Core Data 的运用】

                   在上文,我们介绍了ios开发中的其中2种数据持久化方式:属性列表.归档解档.本节将继续介绍另外2种iOS持久化数据的方法:数据库 SQLite3.Core Data 的运 ...

  6. iOS开发——数据持久化Swift篇&使用Core Data进行数据持久化存储

    使用Core Data进行数据持久化存储   一,Core Data介绍 1,Core Data是iOS5之后才出现的一个数据持久化存储框架,它提供了对象-关系映射(ORM)的功能,即能够将对象转化成 ...

  7. 四种数据持久化方式(下) :SQLite3 和 Core Data

    在上文,我们介绍了iOS开发中的其中2种数据持久化方式:属性列表.归档解档. 本节将继续介绍另外2种iOS持久化数据的方法:数据库 SQLite3.Core Data 的运用: 在本节,将通过对4个文 ...

  8. iOS 数据持久化(3):Core Data

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css); @import url(/ ...

  9. Swift - 使用Core Data进行数据持久化存储

    一,Core Data介绍 1,Core Data是iOS5之后才出现的一个数据持久化存储框架,它提供了对象-关系映射(ORM)的功能,即能够将对象转化成数据,也能够将保存在数据库中的数据还原成对象. ...

随机推荐

  1. go语言:获取字符串长度

    go语言字符串底层由字节数组实现,使用UTF-8编码,初始化以后不能被修改 获取字符串长度 一.当字符串中所有字符都是单字节字符时,使用 len 函数获取字符串的长度 package main imp ...

  2. java 5 绘图GUI

    ---恢复内容开始--- 绘图的基本原理 color 在awt包里面 字体的相关类 Graphics类常用方法 JFrame 继承JFrame就有主窗口了 Java2D API 绘图的例子 了解Swi ...

  3. 2019.9.18 csp-s模拟测试46 反思总结

    神志不清: 回去休息(x)继续考试(√) 非常爆炸的一次考试.看错题码完T1回去再看发现自己过于幼稚,T2读完题看着16mb的空间秒出正解然后逻辑出现致命失误100pts->0pts,T3看了一 ...

  4. python实例 输出你好

    #打开新窗口,输入: #! /usr/bin/python # -*- coding: utf8 -*- s1=input("Input your name:") print(&q ...

  5. Hdu 2389 二分匹配

    题目链接 Rain on your Parade Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 655350/165535 K (Ja ...

  6. Legal or Not HDU - 3342 (拓扑排序)

     注意点: 输入数据中可能有重复,需要进行处理! #include <stdio.h> #include <iostream> #include <cstring> ...

  7. 苹果审核不通过,程序/游戏不兼容IPV6网络

    最近苹果升级的IOS10,所以那边网络环境变成IPV6,如果你的程序不兼容IPV6,苹果的程序会以这个不兼容的原因驳回审核. 那么如何让自己的程序兼容这个?方法其实C#本来已经提供给你的,而且很简单, ...

  8. 优化SQL之最佳索引

    SQL优化工具Tosska SQL Tuning Expert for Oracle,帮助SQL开发人员解决SQL性能问题. 本工具主要创始人Richard To, 资深ITPUB元老,从1996年开 ...

  9. iOS常量(const)、enum以及宏(#define)

    http://www.cocoachina.com/ios/20160530/16483.html 本文投稿文章,作者:SuperMario_Nil(简书) 前言:本文主要梳理iOS中如何使用常量.e ...

  10. oracle-Dbca数据库模板

    数据库模板是用xml文件格式保存在本地磁盘上的数据库配置的定义. Dbca能够使用两种类型的模板:种子模板和非种子模板. 种子模板指含有定义信息和实际的数据文件与重做日志文件的模板定义. 种子模板的优 ...