.Cannot create an NSPersistentStoreCoordinator with a nil model
今天用coredata事,忽然遇到这个问题:找了一会终于发现问题所在,与大家分享一下
导致这个问题的原因是因为找不到.xcdatamodeld所致,不同的人可能遇到的问题不同
可能原因1: NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Model" withExtension:@"momd"];
因为.cxdatamodeld经过编译之后会在.app中生成以个.momd文件,你可以查看一下model文件的名称与你创建的.cxdatamodeld文件名是否相同,不同的话通过URLForResource:@"Model" 名字
可能原因2:系统中根本没有.cxdatamodeld文件,你可能说有啊,那就是没有连接的问题,你可以通过build phases->compile sources 查看.cxdatamodeld是否存在,不存在的点击+号,导入就可以了
如果你的工程中没有.cxdatamodeld文件的话,可以通过newFile->core data->data model 创建.cadatamodeld文件,不过需要导入系统<CoreData/CoreData.h>这个库,手动添加单个属性个两个方法,因为属性是readonly的,所有必须在.m中添加@synthesize生成get和set方法
问题解决后:可能会出现新的问题"The model used to open the store is incompatible with the one used to create the store";
这个时候吧沙盒里的东西清除一下就可以了,或者删除模拟器里的应用,再次运行就好了
.Cannot create an NSPersistentStoreCoordinator with a nil model的更多相关文章
- IOS开发常见错误整理
1.Cannot create an NSPersistentStoreCoordinator with a nil model 这是在执行到这段代码时引发的: - (void)viewDidLoad ...
- iOS教程:如何使用Core Data – 预加载和引入数据
这是接着上一次<iOS教程:Core Data数据持久性存储基础教程>的后续教程,程序也会使用上一次制作完成的. 再上一个教程中,我们只做了一个数据模型,之后我们使用这个数据模型中的数据创 ...
- Tutorial: Model
What is a model? Across the internet the definition of MVC is so diluted that it's hard to tell what ...
- [Backbone]5. Model & View, toggle between Models and Views -- 2
Dr. Goodparts is pretty flaky and has been cancelling a lot of appointments lately. He's asked for a ...
- Django Model 数据表
Django Model 定义语法 版本:1.7主要来源:https://docs.djangoproject.com/en/1.7/topics/db/models/ 简单用法 from djang ...
- ASP.NET Core MVC 2.x 全面教程_ASP.NET Core MVC 08. 输入Model和防止重复Post
通过action的参数传入一个model 通过input的name属性和model属性对应上 通常是使用Http post去做 快速创建了这个Action 这个Action很简单我们只需要返回View ...
- golang文件读写三种方式——bufio,ioutil和os.create
package main import ( "bufio" "fmt" "io/ioutil" "os" ) func ...
- Django Model 定义语法
简单用法 from django.db import models class Person(models.Model): first_name = models.CharField(max_leng ...
- ngrok原理浅析(转载)
之前在进行 微信Demo开发时曾用到过 ngrok这个强大的tunnel(隧道)工具,ngrok在其github官方页面上的自我诠释是 "introspected tunnels to lo ...
随机推荐
- ExceptionDemo
功能: 利用struts.xml 捕获异常 不满足这三个值就报异常 1.web.xml <?xml version="1.0" encoding="UTF-8&q ...
- 理解委托(delegate)及为什么要使用委托
理解委托(delegate)及为什么要使用委托 委托:是一种定义方法签名的类型. 当实例化委托时,您可以将其实例与任何具有兼容签名的方法相关联. 您可以通过委托实例调用方法. 上述为官方说法,理解起来 ...
- ZZNU 1163: 在线判题(指针专题)
题目描述 Ignatius is building an Online Judge, now he has worked out all the problems except the Judge S ...
- ZZNU 1988: Sn
题目描述 给你两个数 n, p(0 < n,p <= 10^15); a1 = 1; a2 = 1+2; a3 = 1+2+3; ... an = 1+2+3+...+n Sn ...
- C#中Invoke的用法
在用.NET Framework框架的WinForm构建GUI程序界面时,如果要在控件的事件响应函数中改变控件的状态,例如:某个按钮上的文本原先叫"打开",单击之后按钮上的文本显示 ...
- 【LeetCode】459. Repeated Substring Pattern
Given a non-empty string check if it can be constructed by taking a substring of it and appending mu ...
- setTimeout 定时器用法
setTimeout($(".msg").slideUp(5000)); msg的div 5秒往上收边 setTimeout("函数名称",1000);
- Python 处理文件
1.从现有文件中获取信息 使用Python中的模块,可以从现有文件中获取信息.使用“os”模块和“stat”模块可以获取文件的基本信息: import os import stat import ti ...
- F#中的自定义隐式转换
我们知道隐式变换在可控情况下会使代码变得简洁.熟悉C#的都知道C#中可以自定义隐式变换,例如 public class A { private int data; public static impl ...
- linux命令 time
功能:用于计算命令执行的世界 语法: time command 例如: hbg@root:~/dl$ time ls111 apple.sh b.txt duplic ...