-1

在 .h 文件中,

NSString *deal_desc,*terms_cond,*merchant_desc,*locationaddress,*locationcity,*locationstate;

试图找到'detailarray'的长度,以便它可以帮助我分配表格中单元格的高度。

deal_desc = @"sadsad dsa dsad dsad sadsa dsad sadsad adsad sadsad adssad sad adsad sada";
terms_cond = @"sadsad adssa sad asdsad&nbsp";
merchant_desc = @"merchant description describes in detail about merchants";

locationaddress =@"42, South St";
locationcity = @"San Jose";
locationstate = @"California";

location = [[NSMutableArray alloc]init];
NSLog(@"location is %@ \n",location);
detaildescription = [[NSMutableArray alloc]init];


[location addObject:locationaddress];
[location addObject:locationcity];
[location addObject:locationstate];

[detailarray addObject:deal_desc];
[detailarray addObject:terms_cond];
[detailarray addObject:location];
[detailarray addObject:merchant_desc];
NSLog(@"detailarray values are %@ \n",detailarray);

在选择表格单元时,我尝试计算'detailarray'中的字符串和数组的长度,这里

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

[tableView deselectRowAtIndexPath:indexPath animated:YES];
[self.tableview beginUpdates];
id1=indexPath.row;
size = [ detailarray[id1] length];
NSLog(@"size of detaildesc is %d \n",size);
 [self.tableview endUpdates];
[tableview reloadData];

}

使我的应用程序崩溃的问题是,找到“位置”长度,错误如下:'-[__NSArrayM 长度]:无法识别的选择器发送到实例 0x717e8e0'

任何人都可以在这方面帮助我。

4

1 回答 1

1

检查 NSMutableArray 大小的正确函数是:

- (int) count;

长度仅适用于 NSString

于 2013-09-11T07:49:00.673 回答