Xcode Debugger: view value of variable

前端 未结 7 775
囚心锁ツ
囚心锁ツ 2020-12-12 14:45

My code in a UITableViewController:

delegate.myData = [myData objectAtIndex:indexPath.row];

How can I see the values of delegate.myDa

相关标签:
7条回答
  • 2020-12-12 15:27

    I agree with other posters that Xcode as a developing environment should include an easy way to debug variables. Well, good news, there IS one!

    After searching and not finding a simple answer/tutorial on how to debug variables in Xcode I went to explore with Xcode itself and found this (at least for me) very useful discovery.

    How to easily debug your variables in Xcode 4.6.3

    In the main screen of Xcode make sure to see the bottom Debug Area by clicking the upper-right corner button showed in the screenshot.

    Debug Area button

    Debug Area in Xcode 4.6.3

    Now set a Breakpoint – the line in your code where you want your program to pause, by clicking the border of your Code Area.

    Breakpoint

    Now in the Debug Area look for this buttons and click the one in the middle. You will notice your area is now divided in two.

    Split Debug Area

    Should look like this

    Now run your application.

    When the first Breakpoint is reached during the execution of your program you will see on the left side all your variables available at that breakpoint.

    Search Field

    You can expand the left arrows on the variable for a greater detail. And even use the search field to isolate that variable you want and see it change on real time as you "Step into" the scope of the Breakpoint.

    Step Into

    On the right side of your Debug Area you can send to print the variables as you desire using the mouse's right-button click over the desired variable.

    Contextual Menu

    As you can see, that contextual menu is full of very interesting debugging options. Such as Watch that has been already suggested with typed commands or even Edit Value… that changes the runtime value of your variable!

    0 讨论(0)
提交回复
热议问题