【发布时间】:2011-12-21 17:27:36
【问题描述】:
设置断点,运行代码。代码暂停,您的变量视图弹出。
通常一切都如我所料。我的对象有小三角形,我可以打开它们并查看它们的内容。有时虽然它们被列为结构。它看起来像......
myCar = (struct Car *) 0x8d85430
并且它没有提供手柄三角形来扩展和检查对象。我转到控制台视图并输入诸如po myCar.color 之类的内容以查看详细信息,因此这比其他任何事情都更令人烦恼。我注意到我的对象在我的代码中的一致位置显示为结构,并且在其他位置看起来相当一致,我只是对原因感到困惑。
我很想了解造成这种现象的原因。
编辑:添加了一些代码。这是一个真实的代码示例,它发生在......有时。下面的代码是来自实现UITableViewDelegate 和UITableViewDataSource 协议的NSObject 子类的sn-ps。
有时当我在transactionDisclaimerCellHeight: 中遇到断点时,我的formatCell 会显示为一个结构体,右键单击并在变量上执行“打印描述”,打印您期望从UITableViewCell 获得的正常描述
-(id)init {
if ((self = [super init])) {
formatCell = [[[[NSBundle mainBundle] loadNibNamed:@"TransactionCell" owner:self options:nil] lastObject] retain];
}
return self;
}
- (NSNumber *)transactionDisclaimerCellHeight:(UITableView *)tableView {
CGRect cellFrame = formatCell.frame;
cellFrame.size.width = [self guesstimateCellWidthFromTableWidth:tableView.frame.size.width];
formatCell.frame = cellFrame;
formatCell.subLabel.text = dataStore.disclaimer;
[RetailUtil dynamicallySizeLabelHeightFor:formatCell.subLabel];
CGFloat cellHeight = [[self getDefaultCellHeight:tableView] floatValue] + formatCell.subLabel.frame.size.height;
return [NSNumber numberWithFloat:cellHeight];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
CGFloat rowHeight = tableView.rowHeight;
if (indexPath.section == kTransactionDetailsSection) {
NSNumber *rowTag = [NSNumber numberWithInt:[self rowTagFromIndexPath:indexPath]];
NSArray *rowData = [transactionTableDataDictionary objectForKey:rowTag];
SEL selector = NSSelectorFromString([rowData objectAtIndex:kCellHeightSelectorIndex]);
rowHeight = [[self performSelector:selector withObject:tableView] floatValue];
}
return rowHeight;
}
【问题讨论】:
-
这也发生在我身上,有一个特定的对象。我也想知道发生了什么,因为这可能会导致其他无法预料的错误(泄漏?)。
-
我认为这与泄漏无关。我刚刚添加了一个代码示例,其中在
init上创建的对象上发生了问题,并且一直持续到dealloc。我真的开始认为这只是调试器中的一个错误。