Many mobile application projects are facing several bugs in the code here or there. And those bugs may be truly irritating but, perhaps, somebody has been facing them earlier and there is a solution already? There is 99% chance that such a solution is already delivered to the world indeed. Thus here is a handy list of old tricks overfilled with wisdom and creativeness for your very own X-code Debugger!
Old dog’s trick # 1
Conditional breakpoints are great for methods that are getting called over and over. If you are willing to check a value of any required variable and are not looking forward of your application breaking you would really want to set up a nice breakpoint. What are you to do in order of setting up some additional breakpoints?
- Set a breakpoint
- Right-click on it (or make a two-finger tap)
- Select the option called ‘Edit breakpoint’
- Enter a value inside (something result==0-ish)
And voilà! You are now capable of making sure there are no values equal to nil or zero.
Old dog’s trick # 2
Bored of all uncaught exceptions being constantly thrown up the stack straight to main? Just tell your Debugger to break once something of that sort happens. What is the benefit of such activity? You will debug your code way faster from this day forth as you will the exact location of where are exceptions tossed in that code of yours. How to get some of that goodness?
- Cmd+6 will take you to the Navigators pane and you are to go to Breakpoint Navigator
- Hit the tiny plus (+) button at the left bottom corner
- ‘Add Exception Breakpoint’ is what you are to select
- Go for ‘Done’ leaving the defaults be
Old dog’s trick # 3
Debugger CLI may grant you nice access to the variables. It may be so nice sometimes to simply see variable’s value without any need of hovering over it. For such exact means typing words like print [self myVariable] in the Debugger console will allow you to see myVariable’s value. But this way is not the ultimate solution as it will be showing you most of information, yet most is not 100%. You will see stuff like the pointer’s value, etc.
But not to worry, there are alternative ways. If your variable is an array you may type a thing like po [self myVariable] and you will see the array’s content. PO is standing for Print Object thus you will be calling the description method on an object. If you have a healthy habit of coding some description methods for your classes you may even enter po self into your Debugger thus getting all info about the current class instance.
There are many more tricks made for assistance, yet a human mind can’t hold all the information it once knew all together ready for you to use. I sincerely hope this article may encourage you to review some of your notes, books and tutorials you used to study testing with. Perhaps you will find a life-saver somewhere around under all that dust.