当我试图在具有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;
}我查看了fetch检索到的managedBobject的类代码,它看起来不错,是从核心数据模型自动生成的类。如果我在同一个fetch中使用模型中的另一个实体,一切都会完美地工作。
想法??
谢谢
发布于 2009-12-09 10:11:13
发现问题:类名列表无效。我将其更改为CheckList,一切正常。
Jk
发布于 2009-12-09 08:50:30
我总是使用检索到的实际实体类--在本例中看起来像"List“--而不是将其称为NSManagedObject (List *list = [fetchedResultsController objectAtIndexPath:indexPath])。我不会仅仅从错误消息中怀疑这一点,但这是我唯一不关心的事情。
编辑:这不太可能是问题所在,但这是我最后的猜测--你确定你导入了"List.h“吗?否则,它可能会认为它只是“id”。它抱怨的方法是用NSObject实现的,所以我无法想象它们不在那里。
发布于 2009-12-09 08:52:48
你的模型类继承自NSObject吗?当情况并非如此时,通常会发生此错误。
https://stackoverflow.com/questions/1870923
复制相似问题