簡體   English   中英

從該部分中刪除最后一行時,NSInternalInconsistencyException

[英]NSInternalInconsistencyException when last row is removed from the section

我有一個使用Core Data處理請求的iPhone 3.0應用程序。 它具有一個視圖,其中所有請求均按請求狀態(sectionNameKeyPath:@“ status”)分組。 它還具有另一個視圖,用戶可以在其中更改請求狀態。

當特定組中有一個行/請求並且用戶編輯該請求的狀態(因此該行所屬的部分應消失)時,我遇到問題,以下代碼引發了異常:

//Change the request status. Request is the NSManagedObject
request.status = [NSNumber numberWithInt:Responded];

// Save the context.
NSError *error;
//The exception is raised at the following line
if (![request.managedObjectContext save:&error]) {
  NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
  abort();  // Fail
}

異常文本如下:

誰能解釋我為什么有此異常以及如何處理?

這表明問題出在您的表修改代碼中。 大概您正在調用[表deleteRowsAtIndexPaths:withRowAnimation:],但不同步-numberOfSectionsInTableView; 和-tableView:numberOfRowsInSection:結果為新值。

暫無
暫無

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

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