.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 ...
随机推荐
- javascript windows对象
1.windows对象方法 2.计时器方法 3.计时器setInterval() <!DOCTYPE HTML> <html> <head> <meta ht ...
- Major and minor numbers
The major nuber is the driver associated with the device, while the minor number is used by the kern ...
- 用Bash脚本将Linux普通用户添加为系统管理员
将Linux普通用户添加为系统管理员在Gnome或KDE这样强大与完善的桌面环境下是非常简单的事情,一般来说在用户设置的对话框里就直接有相应选项.不过,出于简洁与高效的风格,自己目前并未使用这些高端但 ...
- js 获取页面可视区域宽高
获取浏览器窗口的可视区域高度和宽度,滚动条高度有需要的朋友可参考一下. 1.IE中,浏览器显示窗口大小只能以下获取: 代码如下复制代码 代码如下 document.body.offsetWidth d ...
- TakeColor 屏幕取色器 8.0 中文绿色版
软件名称: TakeColor 屏幕取色器软件语言: 简体中文授权方式: 免费软件运行环境: Win8 / Win7 / Vista / WinXP软件大小: 210KB图片预览: 软件简介:使用方便 ...
- NGUI等比缩放
/// <summary> /// UI 等比缩放 /// </summary> static private void AdaptiveUI() { ; ; UIRoot u ...
- MySQL DATE_FORMAT
MySQL DATE_FORMAT(date,format) 根据format字符串格式化date值 (在format字符串中可用标志符: %M 月名字(January……December) %W ...
- hashMap、hashTable、treeMap的区别
1.hashTable是线程安全的.hashMap不是线程安全的 hashmap 线程不安全 允许有null的键和值 效率高一点. 方法不是Synchronize的要提供外同步 有containsva ...
- Git Bash 简单操作
在Windows下使用Git Bash,用的是Linux命令,常用几个文件操作命令如下: Windows命令 Linux命令 意义 cd e:\xxx cd /e/xxx 切换到xxx目录 cd pw ...
- spring框架--IOC容器,依赖注入
思考: 1. 对象创建创建能否写死? 2. 对象创建细节 对象数量 action 多个 [维护成员变量] service 一个 [不需要维护公共变量] dao 一个 [不需要维护 ...