.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 ...
随机推荐
- turn to help
1 'On The Exact Recovery Condition of Simultaneous Orthogonal Matching Pursuit', JF Determe,J Louvea ...
- Design Pattern——Factory_DP
namespace TEST { //用于生成一个对应的操作类,这个工厂只是用来产生操作类的,不做其他只用 public class Factory { public Operate GetOpetr ...
- HDU - 3068 最长回文(manacher)
HDU - 3068 最长回文 Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Subm ...
- HDU 5867 Water problem
处理出1-99的,之后的加上多少hundred和and即可.整百和一千的时候注意一下. #pragma comment(linker, "/STACK:1024000000,10240000 ...
- 为什么PHP(CLI)同一个错误信息会打印两次?
第一个信息是display_errors输出的,在fpm环境下输出到浏览器那里,而在CLI环境下会打印到屏幕上. display_errors = On 第二个信息是log_errors输出的. lo ...
- spring security 1
首先我们为Spring Security专门建立一个Spring的配置文件,该文件就专门用来作为Spring Security的配置.使用Spring Security我们需要引入Spring Sec ...
- 点(.)运算符和箭头(->)运算符的区别
本机中,char类型数据占用1byte, unsigned int, int, long int, float类型的数据占用4 bytes, double类型的数据占用8bytes. 至于指向所有基本 ...
- 多尺度二维离散小波重构waverec2
clc,clear all,close all; load woman; [c,s]=wavedec2(X,2,'haar');%进行2尺度二维离散小波分解.分解小波函数haar %多尺度二维离散小波 ...
- ElasticSearch(3)-原理
参考文档: http://learnes.net/distributed_crud/bulk_requests.html 一.分布式集群 1.1 空集群 单台机器,其中没有数据,也没有索引. 集群中一 ...
- Java ZIP打包
File zipFile = IOUtil.createTempFile("zip"); ZipOutputStream zipout = new ZipOutputStream( ...