打印枚举的字符串表示形式,NSLog [英] Print string representation of an enum, NSLog
本文介绍了打印枚举的字符串表示形式,NSLog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#import< Foundation / Foundation.h>
int main(void)
{
typedef枚举{
SUN,
MON,
TUES
} DAYS;
DAYS d = MON;
NSLog(@%@,d);
return 0;
}
解决方案
LLDB调试器将显示字符串标识符因此,不用使用NSLog,您可以使用一个带有调试器命令操作的断点(在您的情况下为pd),并在断开点后自动继续进行评估。
您可以通过右键单击蓝色标记来配置断点。
I am trying to NSLog some enums I have. For example this piece of code prints the integer representation of the enum, but I want it to output the actual string name, in this case MON. How can I do that?
#import <Foundation/Foundation.h>
int main(void)
{
typedef enum {
SUN,
MON,
TUES
} DAYS;
DAYS d = MON;
NSLog(@"%@", d);
return 0;
}
解决方案
The LLDB debugger will show the string identifiers. So instead of using NSLog you could use a breakpoint with a debugger command action ("p d" in your case) and set the breakpoint to automatically continue after evaluating.
You can configure a breakpoint by right-clicking on the blue marker.
这篇关于打印枚举的字符串表示形式,NSLog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文