在Xcode中,Debug时,不能像eclipse ,或VS那些集成开发那样,能直接查看变量的值。那如何在调试的时候查看
XCode的变量呢?有如下方法:
1、新建一个Single View App在viewDidLoad里添加些代码:
- (void)viewDidLoad
{
[super viewDidLoad];
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:@"value1",@"key1",
@"28", @"age",@"rongfzh",@"name" ,nil];
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(20, 40, 250, 60);
label.text = [dic objectForKey:@"name"];
[self.view addSubview:label];
}
在最后一行打上断点。
2、"po" : print object 命令 打印出对象。Command+R调试运行,在 Debug Console 上lldb上输入po dic回车,显示如下:
这就把词典内容打印出来了。
再打印label试试。
(lldb) po label
(UILabel *) $3 = 0x06a8bdd0 <UILabel: 0x6a8bdd0; frame = (20 40; 250 60); text = 'rongfzh'; clipsToBounds = YES;userInteractionEnabled = NO; layer = <CALayer: 0x6a8be90>>
label的信息也打印出来了。
3、print命令print (char*)[[dic description] cString]
(char *) $4 = 0x06d79760 "{\n age = 28;\n key1 = value1;\n name = rongfzh;\n}"
打印对象的retainCount,但对象被回收
(lldb) print (int)[label retainCount]
(int) $2 = 1
点击查看更多
IOS开发环境
XCode详解。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。