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

这是崩溃日志

类型是音频 2013-06-14 16:09:50.071 ProductivoApp[6516:c503] 音频 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

您的字符串正在获取空值。因此,在比较变量类型时,它的显示错误

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

您正在比较的字符串为空。尝试添加: //only if not null if (string){

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];

} 别的 {

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

}

}

这将确保不会发生空比较

于 2013-06-14T11:16:51.350 回答
0

您的type字符串不等于Audioor Video。当发生崩溃时, type 指的是NSNull. 有关更多信息,请尝试打印此内容,您将获得此内容NSNull

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