我现在有这个可以根据我是否在模拟器中触发 iCloud 加载。当我尝试在真实设备上运行时,出现黑屏并且“addPersistentStore”行似乎挂起。“我的项目名称”是权利文件的名称和应用程序的名称。
这是怎么回事?
#if (TARGET_IPHONE_SIMULATOR)
if (![psc addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:dbUrl
options:nil
error:&error]) {
[NSException raise:@"Open failed" format:@"Reason: %@", [error localizedDescription]];
}
#else
NSFileManager *fm = [NSFileManager defaultManager];
NSURL *ubContainer = [fm URLForUbiquityContainerIdentifier:nil];
NSMutableDictionary *options = [NSMutableDictionary dictionary];
[options setObject:@"My Project Name" forKey:NSPersistentStoreUbiquitousContentNameKey];
[options setObject:ubContainer forKey:NSPersistentStoreUbiquitousContentURLKey];
if (![psc addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:dbUrl options:options error:&error]) {
[NSException raise:@"Open failed" format:@"%@", [error localizedDescription]];
}
#endif