2011-12-21 35 views
2

设置断点,运行代码。代码暂停,您的变量视图弹出。为什么我的对象在调试器中显示为结构?

通常情况下,一切都完全如我所料。我的物品有小三角形,我可以打开它们并戳上它们的内容。有时虽然他们被列为结构。它看起来像...

myCar = (struct Car *) 0x8d85430 

它并没有提供处理三角形来展开和检查对象。我进入控制台视图并输入诸如po myCar.color之类的内容来查看详细信息,因此它比其他任何内容都更令人讨厌。我注意到我的对象在我的代码中显示为结构一致的结构,并且看起来像其他位置的对象相当一致,我只是因为原因而难住。

我很想谈谈这种现象的原因。

编辑:添加了一些代码。这是一个真正的代码示例,它有时会发生。下面的代码是来自实施UITableViewDelegateUITableViewDataSource协议的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; 
} 
+0

这也发生在我身上,有一个特定的对象。我也想知道发生了什么事情,因为这可能会导致其他无法预料的错误(泄漏?)。 – 2012-02-07 17:01:58

+1

我不认为这是与泄漏有关。我刚刚添加了一个代码示例,其中问题发生在我在'init'上创建的对象上,直到'dealloc'。我真的开始认为这只是调试器中的一个错误。 – DBD 2012-02-08 14:03:49

回答

1

是否Car期待一个struct从NSObject继承?许多被认为是Objective-C一部分的功能取决于NSObject

+1

......我想补充一点,它实际上是Cocoa框架的一部分,而不是Objective-C语言的一部分。 – v1Axvw 2011-12-21 17:37:56

+0

好主意,但是汽车确实继承了NSObject – DBD 2011-12-21 18:22:30

相关问题