-1
     cell.theTitle.font=[UIFont fontWithName:@"Helvetical Bold" size:14];
     cell.theTitle.text =[NSString stringWithFormat:@"%@",theCellData.contentTitle];
 cell.theDescriptionLabel.text=theCellData.contentTitle;
 cell.theDateAdded.text=[NSString stringWithFormat:@"Added: %@",theCellData.contentAddedDateTime];


 NSString*type=theCellData.contentType;


 NSLog(@"type is %@",type);


 if ([type isEqualToString:@"Video"]) {

     [cell.theCellImageButton setImage:[UIImage imageNamed:[NSString stringWithFormat:@"Video icon.png",indexPath.row]] forState:UIControlStateNormal];


 }
else if ([type isEqualToString:@"Audio"]) {




    NSLog(@"Audio");
      [cell.theCellImageButton setImage:[UIImage imageNamed:[NSString stringWithFormat:@"Sound icon.png",indexPath.row]] forState:UIControlStateNormal];


}
else {


    [cell.theCellImageButton setImage:[UIImage imageNamed:[NSString stringWithFormat:@"20.png",indexPath.row]] forState:UIControlStateNormal];


}




[cell.theCellImageButton addTarget:self action:@selector(imageButtonAction:) forControlEvents:UIControlEventTouchUpInside];

[cell.theCellImageButton setTag:indexPath.row];




 return cell;

ここにクラッシュログがあります

タイプは Audio 2013-06-14 16:09:50.071 ProductivoApp[6516:c503] Audio 2013-06-14 16:09:50.076 ProductivoApp[6516:c503] -[NSNull isEqualToString:]: 認識されないセレクターがインスタンス 0x125adc8 2013 に送信されました-06-14 16:09:50.079 ProductivoApp[6516:c503] *キャッチされない例外 'NSInvalidArgumentException' が原因でアプリを終了しています。理由: '-[NSNull isEqualToString:]: 認識されないセレクターがインスタンス 0x125adc8 に送信されました'

4

3 に答える 3

0

比較している文字列は null です。追加してみてください: //null でない場合のみ行う if (string){

if ([type isEqualToString:@"Video"]) {

 [cell.theCellImageButton setImage:[UIImage imageNamed:[NSString stringWithFormat:@"Video icon.png",indexPath.row]] forState:UIControlStateNormal];

} そうでなければ ([type isEqualToString:@"Audio"]) {

NSLog(@"Audio");
  [cell.theCellImageButton setImage:[UIImage imageNamed:[NSString stringWithFormat:@"Sound icon.png",indexPath.row]] forState:UIControlStateNormal];

} そうしないと {

[cell.theCellImageButton setImage:[UIImage imageNamed:[NSString stringWithFormat:@"20.png",indexPath.row]] forState:UIControlStateNormal];

}

}

これにより、null 比較が発生しないことが保証されます

于 2013-06-14T11:16:51.350 に答える
0

あなたの文字列はまたはtypeのどちらとも等しくありません。そのクラッシュが発生した場合、型は のインスタンスを参照しています。詳細については、これを印刷してみてください。AudioVideoNSNullNSNull

NSLog(@"%@", [type class]);
于 2013-06-14T11:20:24.090 に答える
0

あなたの文字列は null 値を取得しています。したがって、変数の型を比較す​​ると、エラーが表示されます

 NSString*type=theCellData.contentType;// is null
if ([type isEqualToString:@"Video"]) //error at this line
于 2013-06-14T11:16:08.077 に答える