标签:
+(NSManagedObjectContext *)getContext{
NSManagedObjectModel * model=[NSManagedObjectModel mergedModelFromBundles:nil];
NSPersistentStoreCoordinator * psc=[[NSPersistentStoreCoordinator alloc]initWithManagedObjectModel:model];
NSString * path=[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)firstObject];
path=[path stringByAppendingPathComponent:@"tel.sqlite"];
NSLog(@"%@",path);
NSURL * url=[[NSURL alloc]initFileURLWithPath:path];
[psc addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:url options:nil error:nil];
NSManagedObjectContext * con=[[NSManagedObjectContext alloc]init];
con.persistentStoreCoordinator=psc;
return con;
}
标签:
原文地址:http://www.cnblogs.com/yy515700/p/4523176.html