Objective c 如何在目标c中使persistentStoreCoordinator同步
我是objective c的新手,我想知道如何使Objective c 如何在目标c中使persistentStoreCoordinator同步,objective-c,iphone,ipad,core-data,icloud,Objective C,Iphone,Ipad,Core Data,Icloud,我是objective c的新手,我想知道如何使persistentStoreCoordinator@synchronize使方法线程安全。这是坠机,我能在sigabort上清楚地看到坠机原因 此NSPersistentStoreCoordinator没有持久存储(未知)。它无法执行保存操作 请提供任何链接或示例,以便我们检查persistentstorecordinator是否同步 感谢您的帮助。提前谢谢 -(NSManagedObjectContext*)managedObjectConte
persistentStoreCoordinator
@synchronize
使方法线程安全。这是坠机,我能在sigabort上清楚地看到坠机原因
此NSPersistentStoreCoordinator
没有持久存储(未知)。它无法执行保存操作
请提供任何链接或示例,以便我们检查persistentstorecordinator
是否同步
感谢您的帮助。提前谢谢
-(NSManagedObjectContext*)managedObjectContext
{
@试一试{
if(u managedObjectContext!=nil){
返回uu managedObjectContext;
}
NSPersistentStoreCoordinator*coordinator=[self-persistentStoreCoordinator];
if(协调器!=nil){
__managedObjectContext=[[NSManagedObjectContext alloc]init];
[\uu managedObjectContext setPersistentStoreCoordinator:coordinator];
}
返回uu managedObjectContext;
}
@捕获(NSException*异常){
NSLog(@“异常管理对象上下文:%@”,异常);
}
}
-(NSManagedObjectModel*)managedObjectModel
{
@试一试{
if(u managedObjectModel!=nil){
返回uu managedObjectModel;
}
NSString*modelPath=[[NSBundle mainBundle]pathForResource:DBNAME of type:@“momd”];
if([[TrackerUtilityTrackerUtilityManager]getDebugMode]){
NSLog(@“modelPath%@”,modelPath);
}
NSURL*modelURL=[NSURL fileURLWithPath:modelPath];
__managedObjectModel=[[NSManagedObjectModel alloc]initWithContentsOfURL:modelURL];
返回uu managedObjectModel;
}
@捕获(NSException*异常){
NSLog(@“异常管理对象模型:%@”,异常);
}
}
-(NSPersistentStoreCoordinator*)persistentStoreCoordinator
{
@试一试{
if(uu persistentStoreCoordinator!=nil){
返回uu persistentstorecordinator;
}
NSURL*storeURL=[[self-applicationDocumentsDirectory]URLByAppendingPathComponent:[NSString stringWithFormat:@“%@.sqlite”,DBNAME]];
n错误*错误=nil;
__persistentStoreCoordinator=[[NSPersistentStoreCoordinator alloc]initWithManagedObjectModel:[self-managedObjectModel]];
NSDictionary*选项=@{
NSMigratePersistentStoresAutomaticallyOption:@是,
nsInFermappingModelAutomaticalyOption:@是
};
if(![\uuu persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType配置:nil URL:storeURL选项:选项错误:&错误]){
if([[TrackerUtilityTrackerUtilityManager]getDebugMode]){
NSLog(@“persistentStoreCoordinator错误%@,%@”,错误,[error userInfo]);
}
中止();
}
返回uu persistentstorecordinator;
}
@捕获(NSException*异常){
NSLog(@“异常持久存储协调器:%@”,异常);
}
}
(NSURL*)应用程序文档目录
{
@试一试{
返回[[[NSFileManager defaultManager]URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]lastObject];
}
@捕获(NSException*异常){
NSLog(@“异常应用程序文档目录:%@”,异常);
}
}
添加持久存储可能需要未知的时间。您在哪里初始化核心数据堆栈?您好,Khundragpan,它显示在sigabort上此NSPersistentStoreCoordinator没有持久存储(未知)。它无法执行保存操作。