为什么这不起作用?
(lldb) po [NSString stringWithFormat:@"%f", 1.0]
error: too many arguments to method call, expected 1, have 2
error: 1 errors parsing expression
但这样做:
(lldb) p (void)printf("%f", 1.0)
1.000000
LLDB中不支持Objective-C变量参数语法吗?
答案 0 :(得分:21)
正如Martin R在评论中指出的那样,它显然是general LLDB issue with variable argument lists。
另一方面,作为Patrik Schmittat pointed out,-initWithFormat:
工作正常:
(lldb) po [[NSString alloc] initWithFormat:@"%f", 1.0]
1.000000
我为此提出了一个雷达:rdar://15261415 (stringWithFormat not working in LLDB)
答案 1 :(得分:1)
Basically this is the bug in lldb, if you try the same in gdb it works.
lldb is only passing the low 32 bits of the argument.
请点击此链接Strange behaviours with stringWithFormat float
也是我在GDB中尝试过的东西,并且在屏幕截图中附带的工作很好: -
现在我在GDB中尝试了同样的事情: -