Core data creates an sqlite file with no tables
I am creating an ios application with xcode 4.6.1 which uses core data to save data in the database, i have provided the deployment target as ios 4.3 and the base sdk is set to latest 6.1.
The place where i am stuck is when i run the application on ios 4.3 i see that my sqlite file is created but contains no tables in it. I have wrote no special code here and every thing is by default taken care in the app delegate, i came across few post where other developers have said to
NSURL *modelURL =[[NSBundle mainBundle] URLForResource:@"StudentData" withExtension:@"momd"]; _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
use "mom" above but i even did that and it seems that every time in ios 4.3 this issue pops up, i have also tried and reset my simulator lots of time but nothing seems to be working and i do require ios4.3 support so please let me know what's going on here and what do i need to do.
I also tried printing
NSLog(@"%@",[self managedObjectModel]);
but it's not nil
Please note their is no mistake in the name of the files here.
Thanks
NSBundle *modelWrapper = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"StudentData" ofType:@"momd"]];
NSString *modelPath = [modelWrapper pathForResource:@"StudentData" ofType:@"mom"];
managedObjectModel = [[NSManagedObjectModel alloc]initWithContentsOfURL:[NSURL fileURLWithPath:modelPath]];
By default in Mac OS you don't have write permission.
From terminal go to the path where you have stored your StudentData file and then write this command chmod 777
.
It will allow you to write data in files.
那么,我得到了这个工作,我做的是运行应用程序,看到它创建了sqlite文件,但没有表,但是当我试图用ios 4.3在数据库中插入数据时,数据被插入并且表创建出人意料地它对我来说没有任何意义,但是我没有改变代码中的任何内容就可以工作。
链接地址: http://www.djcxy.com/p/78236.html上一篇: 透明度问题