zoukankan      html  css  js  c++  java
  • iOS-----Xcode-Debug尝试

      在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 "{     age = 28;     key1 = value1;     name = rongfzh; }"

    打印对象的retainCount,但对象被回收

    (lldb) print (int)[label retainCount]

    (int) $2 = 1

  • 相关阅读:
    csu 1965
    csu 1947 三分
    Codeforces 336C 0-1背包
    POJ 1743 后缀数组
    POJ 2774 后缀数组
    UVA 12333 大数,字典树
    POJ 2942 圆桌骑士
    POJ 1503 大整数
    POJ 2342 树的最大独立集
    POJ 3088 斯特林
  • 原文地址:https://www.cnblogs.com/LifeTechnologySupporter/p/5295466.html
Copyright © 2011-2022 走看看