設置斷點,運行代碼。代碼暫停,您的變量視圖彈出。爲什麼我的對象在調試器中顯示爲結構?
通常情況下,一切都完全如我所料。我的物品有小三角形,我可以打開它們並戳上它們的內容。有時雖然他們被列爲結構。它看起來像...
myCar = (struct Car *) 0x8d85430
它並沒有提供處理三角形來展開和檢查對象。我進入控制檯視圖並輸入諸如po myCar.color
之類的內容來查看詳細信息,因此它比其他任何內容都更令人討厭。我注意到我的對象在我的代碼中顯示爲結構一致的結構,並且看起來像其他位置的對象相當一致,我只是因爲原因而難住。
我很想談談這種現象的原因。
編輯:添加了一些代碼。這是一個真正的代碼示例,它有時會發生。下面的代碼是來自實施UITableViewDelegate
和UITableViewDataSource
協議的NSObject的子類的片段。
有時候我formatCell
出現,當我打了transactionDisclaimerCellHeight:
點擊鼠標右鍵斷點,這樣做對可變印刷「打印說明」正常說明你從一個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;
}
這也發生在我身上,有一個特定的對象。我也想知道發生了什麼事情,因爲這可能會導致其他無法預料的錯誤(泄漏?)。 – 2012-02-07 17:01:58
我不認爲這是與泄漏有關。我剛剛添加了一個代碼示例,其中問題發生在我在'init'上創建的對象上,直到'dealloc'。我真的開始認爲這只是調試器中的一個錯誤。 – DBD 2012-02-08 14:03:49