Is it possible to change BOOL value while debugging in Xcode?
Asked Answered
W

3

5

Is it possible to change the value of the BOOL from true to false or vice-versa while I'm in debugging mode?

Weep answered 2/5, 2012 at 20:29 Comment(2)
You mean change the value of a variable?Murvyn
Yes. Say the value of BOOL is YES(true), and if I stop at a breakpoint, how do I change the value of that BOOL?Weep
W
3

In the Xcode debugger where it shows the local var values you can double-click on a value and edit it while you're stopped at a breakpoint too. This can be faster than typing the whole thing in the console.

Woken answered 2/5, 2012 at 20:54 Comment(4)
If I double click and change the value of the variable and press ENTER, it return back to its original value. Any suggestions?Weep
Most of the debugger things are the same or very similar in LLDB and GDB. But there are differences. LLDB is the future, but GDB is more complete (for now).Woken
@Malcolm, how does one change the debugger?Yap
expr var = false (not NO) will do it with LLDBArchivist
T
4

With LLDB debugger:

If you run your code and stop on that break point, you can just type:

expr myString = @"New string" expr myBooleanValue = NO

etc.

Truitt answered 4/2, 2014 at 16:18 Comment(0)
W
3

In the Xcode debugger where it shows the local var values you can double-click on a value and edit it while you're stopped at a breakpoint too. This can be faster than typing the whole thing in the console.

Woken answered 2/5, 2012 at 20:54 Comment(4)
If I double click and change the value of the variable and press ENTER, it return back to its original value. Any suggestions?Weep
Most of the debugger things are the same or very similar in LLDB and GDB. But there are differences. LLDB is the future, but GDB is more complete (for now).Woken
@Malcolm, how does one change the debugger?Yap
expr var = false (not NO) will do it with LLDBArchivist
B
0

I think that you can, if you have BOOL var = NO; in the console, after (gdb), type set var = YES, for example. You can verify the value by entering po var into the console.

Bucko answered 2/5, 2012 at 20:51 Comment(1)
for primitive types, you'll want to log using p instead of poAdmiral

© 2022 - 2024 — McMap. All rights reserved.