开发者

XCode 4 - watching values of custom variable during debug

开发者 https://www.devze.com 2023-03-27 09:31 出处:网络
I am new to xcode and I just have a quick question. In Visual Studio and Eclipse, I can add custom variables to a windows

I am new to xcode and I just have a quick question. In Visual Studio and Eclipse, I can add custom variables to a windows and watch its values during a debug session. I am looking for the same feature in Xcode 4, but I cannot find it. If it is possible in Xcode, could you please provide instruction so that I can do what I wish to do. If this is not possible, please let me know.

I am only able to find t开发者_高级运维he window for variables that are "local", or "auto", or "all".

Thanks in advance.


Right click in that same window (that has the toggles for Local, Auto, All) and click Add Expression. Type in the full expression and click Done. The new watch expression should show when debugging in the window in the lower left with an E next to it.


Also, if you don't want to mess about with the IDE too much you can use gdb for this.

Click in the output window of the debugger and type po variable_name and it will print out the value of that variable at that time.

e.g

(gdb) po mArray

(gdb) __NSArray object1, object2 ... etc`

You can also use print variable_name to get the value of a variable.


To print the variable in console,

    NSString *str1 = @"First String";
    NSLog(@"%@", str1);
    int counter = 7;
    NSLog(@"%i", counter);

And you want to see with out printing,

  1. Put breakpoint at desired position and as its break the running application, take pointer to the variable and it will show you an one lined popup with gray colored arrow.
  2. As you point to that gray colored arrow, two tiny arrows with up-down indication will show.
  3. As you tap on those arrows, a pop will come and choose first option, "Print Description" and it will show you the value of desired variable.
0

精彩评论

暂无评论...
验证码 换一张
取 消