0

I am new to Xcode and don't have experience using lldb the debugging tool. I am following the tutorial here from Apple. I noticed that lldb tool gives me some opposite info about a variable I am hovering my mouse over. How does this happen?

Screen shot 2

user3207158
  • 619
  • 2
  • 5
  • 22
  • 1
    Your mouse is hovered on line `127` where it was still `false`. Then you stepped to `128` and did `po` where it's already true – janusfidel Aug 22 '18 at 22:06
  • @janusbalatbat I uploaded another screen shot. The variable `isPresentingInAddMode` is evaluated false therefore the block between line 128 and 129 is not entered. lldb says the boolean is true. – user3207158 Aug 22 '18 at 22:22
  • Sometimes happens that the GUI doesn’t get updated values. But judging from the breakpoint line i’d surpridingly trust the one hovered. Can you reproduce it also after usual deep-cash-clean and xcode restart? – jalone Aug 22 '18 at 22:36
  • @jalone: Same thing happens after I cleaned the build folder, deleted DerivedData folder, restarted XCode and computer. – user3207158 Aug 23 '18 at 16:41

1 Answers1

0

I have some interest findings. I am posting them here for the community because I haven't seen any similar answers on SO. However it is more like a clue, not really an "answer" per se.

After reading this SO answer, I played a little more with lldb. Here is one thing I tried:

let v1: Int? = nil
let v2 = (v1 is String)
let v3 = (v1 is Int?)
let v4 = (v1 is Int)

and then I did p and po on them...

|---------|----------|----------|----------|----------|
|         |    v1    |    v2    |    v3    |    v4    |
|    p    |   nil    |   false  |   true   |   false  |
|    po   |   nil    |   true   |   true   |   true   |
|---------|----------|----------|----------|----------|

I can definitely relate this experiment to the original situation I had where presentingViewController is also nil. It looks like the command po, that prints the description of an object, will display true to "any OptionalVariable is any type" statements.

I am still researching more on this and looking for official documentations...

user3207158
  • 619
  • 2
  • 5
  • 22
  • I can't reproduce the results of your experiment with the Xcode 10 beta. If I put your snippet in a .swift file as the body of a () -> Void function, and stop AFTER all the assignments have been run, then `po` & `p` return consistent and correct results. Can you present a complete example? Also, what version of Xcode are you using? – Jim Ingham Aug 23 '18 at 20:32
  • @JimIngham. I did reproduce the same result after putting the code ina separate ()->Void function. I am using XCode 9.2 with Swift 4.0 – user3207158 Aug 24 '18 at 17:53