【发布时间】:2013-05-16 18:51:18
【问题描述】:
我可以向 UITableView 添加文本,但是当我尝试向 detailTextLabel 添加某个曾经是 NSDate 的字符串时,应用程序崩溃并显示:
'NSInvalidArgumentException', reason: '-[__NSDate isEqualToString:]:
unrecognized selector sent to instance 0x8383690'
我可以在detailTextLabel 中添加一个普通的虚拟NSString,所以我不明白。有什么帮助吗?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
NSString* temp = [biggerDateA objectAtIndex:indexPath.row];
cell.textLabel.text = [bigA objectAtIndex:indexPath.row];
//cell.detailTextLabel.text = [biggerDateA objectAtIndex:indexPath.row];
//cell.detailTextLabel.text = @"Date Goes here";
cell.detailTextLabel.text = temp;
[bigA retain];
//[biggerDateA retain];
return cell;
}
【问题讨论】:
-
“曾经是 NSDate 的字符串”?什么意思?
-
你确定
certain string是string类型吗? -
biggerDateA持有什么类型的对象?看起来像NSDate对象。当然,您不能将text属性设置为日期。 -
您几乎可以肯定是在尝试将 NSDate 分配给标签。
标签: ios objective-c uitableview nsstring