Xcode fetchedResultsController和Integer

Xcode fetchedResultsController和Integer,xcode,xcode4,nsfetchedresultscontroller,Xcode,Xcode4,Nsfetchedresultscontroller,我正在从包含两个字符串和一个整数的实体更新TableViewController。字符串工作正常,而整数工作不正常。这是我的密码 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UsersCell *cell = [table

我正在从包含两个字符串和一个整数的实体更新TableViewController。字符串工作正常,而整数工作不正常。这是我的密码

     - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UsersCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (!cell) {
        cell = [[GolfersCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    }

    Users *users = [_fetchedResultsController objectAtIndexPath:indexPath];

    cell.firstName.text = users.firstName;
    cell.lastName.text = users.lastName;
        int i = [users.gendID intValue] ;
    cell.genID.text = [NSString stringWithFormat:@"%d", i];

    [self configureCell:cell atIndexPath:indexPath];

    return cell;
}
现在,这确实起作用了,注释掉了“inti=[users.gendID intValue];”行,将其保留在其中,并逐步遍历程序返回的错误

2012-04-30 16:49:02.369 My App [9757:fb03] -[Users gendID]: unrecognized selector sent to instance 0x6b8a6c0
2012-04-30 16:49:02.373 My App[9757:fb03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Users gendID]: unrecognized selector sent to instance 0x6b8a6c0'
*** First throw call stack:
(0x16b0022 0x1841cd6 0x16b1cbd 0x1616ed0 0x1616cb2 0x3a6d 0xb5c54 0xb63ce 0xa1cbd 0xb06f1 0x59d21 0x16b1e42 0x2068679 0x2072579 0x1ff74f7 0x1ff93f6 0x1ff8ad0 0x168499e 0x161b640 0x15e74c6 0x15e6d84 0x15e6c9b 0x15997d8 0x159988a 0x1b626 0x28bd 0x2825)
terminate called throwing an exception(lldb)

在我看来,这像是一个打字错误。在代码中,用户属性名为gendID,而单元格属性为genID。“未识别的选择器发送到实例”表示没有为该类定义此类方法。验证您的Users类是否确实包含名为“gendID”的方法/属性。

除了Lighforce的建议之外,您不应该在两个位置加载单元格内容。在设置了名字、姓氏和genID之后,您的代码将在索引路径处调用configure单元。问题可能在于这种方法。将设置代码放在一个地方或另一个地方,但不要将其放在两种方法之间