Xcode Debugging Tips

Xcode debugging is very useful feature while coding. In the number of the Xcode debugging features, there is a useful one I have recently discovered.

As we know, we can easily print all variables in the debugging sesion variable list.

For example:

po anArray
po aString
po evenViewObjects

As I write in the examples, we can print all kind of view objects that inherited from UIView object. What if we should change a property of a view object. For example text of UILabel.

Let’s look at what we should write for this. You can download basic project here to test yourself.

Here is the initial screen of the app, we are going to change text property of label(aLabel) and backgroundColor property of button(aButton):

Initial state of the app

This is what we see when we debug the app and print the aLabel:

Printing text property:

And changing it:

And boom! We have just changed the text here without re-build and re-run:

After changing the text of label

Let’s print the aButton:

Then print the backgroundColor property of aButton:

And changing it to redColor:

Boom! We have changed the background color of button from blue to red:

After changing the background color of button

Here as you see, we can easily debug and change property of UIView object in debugging. With this, we don’t have to re-build and re-run again and again for minimal changes.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.