根據我是否在模擬器中,我現在有權立即觸發iCloud加載。當我嘗試在真實設備上運行時,出現黑屏,'addPersistentStore'行似乎掛起。 「我的項目名稱」是權利文件的名稱和應用程序的名稱。嘗試在手機上啓動iCloud應用程序時出現黑屏
發生了什麼事?
#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
否。該行返回正常。這是掛起的addPersistentStore。 –
我仍然會嘗試在不同的線程上運行它。在這個SO問題有人有相同的問題:http://stackoverflow.com/questions/12923238/ios-application-freezing-on-first-launch-when-icloud-is-enabled –
這是好的建議,無論哪種方式 – DGund