【发布时间】:2009-12-31 18:11:35
【问题描述】:
这张截图说明了一切:
屏幕截图显示调试器报告 buttonType 为 2,但控制台显示按钮类型 = 0。调试器和控制台中显示了相同的变量。知道这种不匹配是如何发生的吗?
(gdb) po ((UIButton *)control).buttonType
没有名为 buttonType 的成员。
根据要求:
NSLog(@"################ CALL OUT ACCESSORY TAPPED: set pinColor to RED in call out accessory tapped");
NSLog(@"################ CALL OUT ACCESSORY TAPPED: UIButtonTypeDetailDisclosure = %d",UIButtonTypeDetailDisclosure);
NSLog(@"################ CALL OUT ACCESSORY TAPPED: control button type = %d", ((UIButton *)control).buttonType);
if (((UIButton *)control).buttonType == 2) {
NSLog(@" ############# CALL OUT ACCESSORY TAPPED: in buttonType = disclosure");
leftCallOutButton.available = YES;
}
if 语句的计算结果为假!!试图理解为什么 buttonType 被报告为 2 (如果 fact 是用 type 2 创建的)
根据 Mike 的要求:
(gdb) p (int) [((UIButton *)control) buttonType]
$1 = 0
2009-12-31 14:04:26.821 iParkNow![4432:207] ################ CALL OUT ACCESSORY TAPPED: control button type = 0
(gdb) p (int) [((UIButton *)control) buttonType]
好的,所以这更有意义。现在的问题是为什么 buttonType 会从 2 变为 0?它使用 buttonType 2 创建并以某种方式更改为 0。有什么想法吗??
【问题讨论】:
-
@ennukiller:您能否给我们来自
NSLog()调用的代码,该调用输出“UIButtonTypeDetailDisclosure = 2”到输出“控制按钮类型 = 0”的NSLog()调用,包括这两行?这可能会有所帮助。 -
@John,根据您的要求发布。
-
@ennukiller:你试过运行我修改后的命令吗?可以发一下结果吗?
-
@ennukiller,我想你的意思是我。命令是
p (int) [((UIButton *)control) buttonType] -
@ennukiller:谢谢。非常有趣,起初我以为我发现了它,然后我意识到我的错误。我发现有趣的是
po ((UIButton *)control).buttonType在(在您的断点处)您已经执行了完全相同的代码行时没有找到这样的成员。po control呢?诚然,这将是大量无关的数据,但它可能会提供更多洞察力。
标签: objective-c xcode debugging