2012-05-01 12 views
0

2つの文字列と1つの整数を含むエンティティからTableViewControllerを更新しています。文字列は整数が正しく動作しません。ここに私のコードです。fetchedResultsControllerとInteger

 - (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; 
} 

は、今は、この行をコメントアウト、作業を行う "INTをI = [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) 

答えて

0

これは私にとって誤植のようです。あなたのコードでは、あなたのセルのプロパティがgenIDである間にユーザープロパティ名はgendIDです。 「インスタンスに送信された認識できないセレクタ」は、そのクラスに対して定義されたメソッドが存在しないことを意味します。 Usersクラスに実際に "gendID"という名前のメソッド/プロパティが含まれていることを確認します。

1

Lighforceの提案に加えて、セルコンテンツを2か所に読み込んではいけません。姓、名、genIDを設定したら、コードはconfigure pathをindex pathで呼び出します。その方法に問題がある可能性があります。あなたの設定コードを1か所に入れてください。しかし、2つの方法の間でそれを飛ばしてはいけません。

関連する問題