簡體   English   中英

在核心數據標准遷移過程中應用崩潰,沒有錯誤

[英]App crashing during Core Data standard migration without error

嘗試使用標准遷移更新核心數據時,該應用程序崩潰且沒有錯誤消息。 它具有直到此為止的所有標准日志消息:

CoreData: sql: INSERT INTO ZENTRY(Z_PK, Z_ENT, Z_OPT, ZLOCATION, ZBOOKMARKED, ZCREATIONDATE, ZENTRYID, ZMESSAGE, ZSECTIONIDENTIFIER, ZTICDSSYNCID, ZVERSION) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
CoreData: sql: COMMIT
CoreData: sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZISINPHOTOLIBRARY, t0.ZLARGETHUMBNAIL, t0.ZMOVIE, t0.ZORIGINALHEIGHT, t0.ZORIGINALIMAGE, t0.ZORIGINALWIDTH, t0.ZSCREENSIZEIMAGE, t0.ZTHUMBNAIL, t0.ZTYPE, t0.ZENTRY, t0.Z_FOK_ENTRY FROM ZMEDIA t0 

它停留了幾秒鍾,然后崩潰到主屏幕,沒有更多日志消息。

崩潰之前的代碼是:

persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];

NSURL *storeUrl = [NSURL fileURLWithPath:storePath];
    NSError *error;
    NSDictionary *pscOptions = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
                                [NSNumber numberWithBool:NO], NSInferMappingModelAutomaticallyOption,
                                nil];

然后它在此行崩潰:

if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:pscOptions error:&error]) {

        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    } 

它甚至沒有達到那個未解決的錯誤行。

也許您遇到了我在此處的答案中描述的相同問題(您修改了模型而不創建新的模型版本)。

一個對您有用的好幫手可以在@try @catch塊中將問題換行,並查看它捕獲的內容:

@try
{
    if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:pscOptions error:&error])
    {
        NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    }
}
@catch(NSException* ex)
{
    NSLog(@"Exception: %@", ex);
}

它有助於理解問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM