[英]NSFetchedResultsController problem
當我嘗試在具有NSFetchedResultsController的UITableViewController中設置單元格時,一旦嘗試進入managedObject,就會收到錯誤消息。 錯誤是:
2009-12-08 16:21:47.610 Take10[4837:20b] *** NSInvocation: warning: object 0xa08dd140 of class 'List' does not implement methodSignatureForSelector: -- trouble ahead
2009-12-08 16:21:47.610 Take10[4837:20b] *** NSInvocation: warning: object 0xa08dd140 of class 'List' does not implement doesNotRecognizeSelector: -- abort
這是我的代碼,嘗試設置托管對象時會崩潰:
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// Get the managedObject
NSManagedObject *managedObject = [fetchedResultsController objectAtIndexPath:indexPath];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell...
cell.textLabel.text = [managedObject valueForKey:@"listName"];
return cell;
}
我已經看過了通過提取檢索到的ManagedBobject的類代碼,它看起來很好,它是從Core Data模型自動生成的類。 如果我在相同的訪存中使用模型中的另一個實體,則一切工作正常。
想法?
謝謝
我一直使用實際檢索到的Entity類-在您的情況下看起來像“ List”-而不是將其稱為NSManagedObject
( List *list = [fetchedResultsController objectAtIndexPath:indexPath]
)。 我不會僅僅從錯誤消息中就懷疑到這一點,但這是我唯一看到的東西。
編輯:這不太可能是問題,但這是我的最后猜測-您確定導入了“ List.h”嗎? 否則,它可能會認為這只是“ id”。 它抱怨的方法是在NSObject中實現的,所以我無法想象它們不存在。
發現了問題:類名列表無效。 我將其更改為CheckList,一切都很好。
JK
您的模型類是否繼承自NSObject? 如果不是這種情況,通常會發生此錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.