Reputation: 305
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
Upvotes: 0
Views: 551
Reputation: 305
Well, i got this working what i did was ran the application and saw that it created the sqlite file but with no tables but when i tried to insert the data in the database with ios 4.3 then the data got inserted and tables were created surprisingly it did not make any sense to me but i got this working without changing anything in the code.
Upvotes: 0
Reputation: 590
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.
Upvotes: 0
Reputation: 4091
NSBundle *modelWrapper = [NSBundle bundleWithPath:[[NSBundle mainBundle] pathForResource:@"StudentData" ofType:@"momd"]];
NSString *modelPath = [modelWrapper pathForResource:@"StudentData" ofType:@"mom"];
managedObjectModel = [[NSManagedObjectModel alloc]initWithContentsOfURL:[NSURL fileURLWithPath:modelPath]];
Upvotes: 0