Debugging
iOS Developer Tips - Visitor Stats:
|
|
|
Debugging with GDB: Print-Object and UIView recursiveDescription
In the post Debugging with GDB: Introduction to Commands, Print and Print-Object I covered the basics of the command line inteface in GDB. In this post I’ll show you a trick to print out the entire view hierarchy for UIView objects. In Objective-C, all objects (derived from NSObject) have a description method, which returns an [...]
Updated: Tracking Down EXC_BAD_ACCESS Errors with NSZombieEnabled in Xcode 4
In a previous post Tracking Down EXC_BAD_ACCESS Errors with NSZombieEnabled I explained how the environment variable NSZombieEnabled can help track down EXC_BAD_ACCESS errors, which are typically caused by attempting to access objects that have already been released. With Xcode 4 the process for setting NSZombieEnabled is different than in earlier versions of Xcode. To configure [...]
Debugging with GDB: Introduction to Commands, Print and Print-Object
GDB is the debugging system built into Xcode. Xcode handles much of the interaction with GDB to provide support for breakpoints, stepping through/over code, wowever, GBD also provides a command line that you can use to work directly with the debugger. This tutorial walks through the basics of the command line interface along with an [...]
Objective-C Expressions for Debugging
In a previous post I wrote about preprocessor macros that provide filename, line number and function information to aid in debugging. A short example follows: – (void)buttonPressed:(UIButton *)button { NSLog(@"\n Function: %s\n Pretty function: %s\n Line: %d\n File: %s\n Object: %@", __func__, __PRETTY_FUNCTION__, __LINE__, __FILE__, button); … }
Xcode 4 : Debug Breakpoints, Conditions and Actions
I recently bumped into a few new debugging features in Xcode 4 while looking at breakpoint options. To show how this works, let’s look at a small block of code where I’ve already set a breakpoint by clicking in the margin area on the left side in the editor:
Locating Crash Reports
If an applications crashs while running on a device, iOS logs the errors and creates a crash report. The report includes specifics about the OS version, date/time, the exception type, a stack trace, among other details. Below is a partial listing of a report:
Share and Copy Files Between an App and iTunes
You can share files between an iOS app and your Mac using file sharing via iTunes. Using file sharing the contents of your application’s Documents directory is available in iTunes. This also works the other way, where you can place files from your Mac into the shared area of iTunes and make them available to [...]
Exceptions – Try, Catch and Finally
You won’t find exceptions used as frequently in Objective-C as in other languages. However, try/catch/finally blocks can be useful to capture errors that may otherwise cause an app to fail. In the example below, I allocate an array, however I don’t add any elements to the array. Inside the try block the attempt to access [...]
Working with Assertions to Debug your Apps
Assertions provide a mechanism to catch errors by checking a condition statement(s) and throwing an exception if the condition check fails. Assertions are implemented as macros that you can use to evaluate conditions at various points in your application. Often times assertions are used as a sanity check to verify variables contain the values, or [...]
Tracking Down EXC_BAD_ACCESS Errors with NSZombieEnabled
It’s only a matter of time before you’ll find yourself face to face with the dreaded EXC_BAD_ACCESS error message. This message generally occurs when you attempt to access an object that has previously been released. NSZombieEnabled is an environment variable which can be helpful to track down the elusive object causing the problem. With the [...]
Debugging Macros
In a previous post, Yet Another Debug Output Replacement, I wrote a macro that I prefer over NSLog as the output does not prepend the date/time and object information that NSLog does. Since that time I’ve pulled together a few more macros that I use on a regular basis for printing debug information on rectangles, [...]
Write Debug Output to a File
NSLog definitely has its place in debugging. In a previous post I shared a version I wrote that skips displaying the date and object information, you can read more about the debug command I use on a regular basis here.
Yet Another Debug Output (NSLog Replacement)
Although NSlog is convenient for outputting messages to the console, I tire of the date/time and object information that it prints. As an alternative, one can craft a macro that uses CFShow, which outputs Core Foundation objects to stderr. CFShow uses callbacks to objects to display their descriptions, which allows one to use “%@” like [...]






