2011-10-26 10 views
1

新しいiOS5 TableViewスタイルのコードを使用していますが、問題が発生しているようです。 searching = true関数が呼び出されるたびにクラッシュします。私はそれがtriinedであると思って、UITableViewオブジェクトをconfigureメソッドに渡し、BadgedCellを受け入れます。任意のアイデアをどのようにこれを修正するには?UITableViewCellで問題が発生しました

Crash says: 2011-10-25 22:21:04.973 Social[5719:707] -[__NSCFDictionary isEqualToString:]: unrecognized selector sent to instance 0x392510 

2011-10-25 22:21:04.975 Social[5719:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary isEqualToString:]: unrecognized selector sent to instance 0x392510' 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if(searching) 
    { 
     UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SearchCell"]; 
     [self configureCell:cell atIndexPath:indexPath]; 
     return cell; 
    } 
    else 
    { 
     TDBadgedCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BadgedCell"]; 
     [self configureCell:cell atIndexPath:indexPath]; 
     return cell; 
    } 
} 

- (void)configureCell:(TDBadgedCell *)cell atIndexPath:(NSIndexPath *)indexPath 
{ 
    if(searching) 
    { 
     NSDictionary *dictionary = (NSDictionary *)[listOfItems objectAtIndex:indexPath.row]; 
     [cell.textLabel setText:[dictionary objectForKey:@"exerciseName"]]; 
     [cell.detailTextLabel setText:[dictionary objectForKey:@"muscleName"]]; 
     cell.textLabel.text = [listOfItems objectAtIndex:indexPath.row]; 
     cell.detailTextLabel.text = [listOfItems objectAtIndex:indexPath.row]; 
    } 
    else 
    { 
     cell.textLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:16]; 
     cell.textLabel.text = [[self.muscleArray objectAtIndex:indexPath.row]objectForKey:@"muscleName"]; 
     cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    } 
} 

答えて

0

あなたが理由であれば、先行する3つのラインとして、あなたのconfigureメソッド内からこれらの2行を削除する必要が意味するものでは、テキストフィールドとして辞書を設定しようとしているあなたの「listOfItems」辞書のリストが続いていますあらゆる種類の問題を引き起こすtextLabelの

cell.textLabel.text = [listOfItems objectAtIndex:indexPath.row]; 
cell.detailTextLabel.text = [listOfItems objectAtIndex:indexPath.row]; 
2

あなたは、セルに文字列としてlistOfItems辞書を渡している。

あなたはこれを使用した場合:

 NSDictionary *dictionary = (NSDictionary *)[listOfItems objectAtIndex:indexPath.row]; 

私はlistOfItemsは多くの辞書が含まれていることを理解しています。 は、だから、呼び出すとき:あなたは基本的には、セルのラベルに辞書を割り当てるしようとしている

cell.textLabel.text = [listOfItems objectAtIndex:indexPath.row]; 
    cell.detailTextLabel.text = [listOfItems objectAtIndex:indexPath.row]; 

。 Xcodeがあなたに[__NSCFDictionary isEqualToString:]と言っている理由です。

これらの行を削除してみます。

関連する問題