Sunday, July 8, 2012

Xcode Debugger

Apple Xcode debugger documentation
Also, Paul Hegarty's Debugger Video on iTunes.

The debug console (lower right) has a prompt (e.g. (gdb) or (lldb)) where you can enter commands to get some feedback about objects at the current breakpoint.

(lldb) print self

(lldb) po [self someObjectGetter]


You can also do conditional breakpoints.  Conditional breakpoints mean that at some point in your program you only want a breakpoint to interrupt your program when a certain 'condition' exists.  For example, if you have an int value variable and you only want it to break when the value == 3.

To make a breakpoint conditional in Xcode, right-click on the breakpoint and select 'Edit Breakpoint' from the popup menu.  A little popup dialog (see image) will be presented.  Enter the desired condition and click done.

Saturday, July 7, 2012

Xcode crash dialog


How do you traverse an NSArray?


From HERE

NSEnumerator *e = [array objectEnumerator];
id object;
while (object = [e nextObject]) {
  // do something with object
}

Friday, July 6, 2012

Another implementation plan


Screen: Performance Dashboard


Screen: Share your Accomplishments


GHUnit

If you are using Xcode 4.3.3 (or greater), when you modify your Tests/Supporting Files/main.m you will need to perform  slightly different:
  • Add #import <GHUnitIOS/GHUnitIOSAppDelegate.h>
  • Add 

return UIApplicationMain(argc, argv, nil, NSStringFromClass([GHUnitIOSAppDelegate class]));


So you end up with at least two targets.  One target for the main project (MyTestableApp) and one target for the testing area (Tests).  In order to test classes from the main project you will need to add them to the "Compile Sources" section of the Tests target's Build Phases:



GHAssertNoErr(a1, description, ...)
GHAssertErr(a1, a2, description, ...)
GHAssertNotNULL(a1, description, ...)
GHAssertNULL(a1, description, ...)
GHAssertNotEquals(a1, a2, description, ...)
GHAssertNotEqualObjects(a1, a2, desc, ...)
GHAssertOperation(a1, a2, op, description, ...)
GHAssertGreaterThan(a1, a2, description, ...)
GHAssertGreaterThanOrEqual(a1, a2, description, ...)
GHAssertLessThan(a1, a2, description, ...)
GHAssertLessThanOrEqual(a1, a2, description, ...)
GHAssertEqualStrings(a1, a2, description, ...)
GHAssertNotEqualStrings(a1, a2, description, ...)
GHAssertEqualCStrings(a1, a2, description, ...)
GHAssertNotEqualCStrings(a1, a2, description, ...)
GHAssertEqualObjects(a1, a2, description, ...)
GHAssertEquals(a1, a2, description, ...)
GHAbsoluteDifference(left,right) (MAX(left,right)-MIN(left,right))
GHAssertEqualsWithAccuracy(a1, a2, accuracy, description, ...)
GHFail(description, ...)
GHAssertNil(a1, description, ...)
GHAssertNotNil(a1, description, ...)
GHAssertTrue(expr, description, ...)
GHAssertTrueNoThrow(expr, description, ...)
GHAssertFalse(expr, description, ...)
GHAssertFalseNoThrow(expr, description, ...)
GHAssertThrows(expr, description, ...)
GHAssertThrowsSpecific(expr, specificException, description, ...)
GHAssertThrowsSpecificNamed(expr, specificException, aName, description, ...)
GHAssertNoThrow(expr, description, ...)
GHAssertNoThrowSpecific(expr, specificException, description, ...)
GHAssertNoThrowSpecificNamed(expr, specificException, aName, description, ...)