More Objective-C cocoa gotchas.

Firstly… when you’re chopping and changing lots of files in and out (and using the refactoring functions to rename classes by highlighting the name and hitting apple-option-j) you can get linking errors of all sorts afterwards and strange crashes saying that NIB files could not be loaded despite them clearly being in your project. In this instance look under Targets->Project Name and Copy Bundle Resources to ensure the NIB files are present and Compile Sources to ensure your souce code is present (not headers). You can find they are missing so despite being in the project they are not part of the compilation process. Simply drag them back in.

Also this article is fantastic for debugging EXC_BAD_ACCESS errors:

Debbuging Autorelease

For example, this is awesome:

Cooking Companion(38689,0xa0366500) malloc: *** error for object 0x6669134: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
Program received signal: “SIGABRT”.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe to call dlopen at this time.)
(gdb) shell malloc_debug 38689 0x6669134
bash: malloc_debug: command not found
(gdb) shell malloc_history 38689 0x6669134
malloc_history Report Version: 2.0
Process: Cooking Companion [38689]
Path: /Users/diziet/Library/Application Support/iPhone Simulator/4.1/Applications/12953D32-17B6-4E16-BE10-4AED1385C675/Cooking Companion.app/Cooking Companion
Load Address: 0x1000
Identifier: Cooking Companion
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: gdb-i386-apple-darwin [38691]

Date/Time: 2010-08-08 18:34:08.597 +0100
OS Version: Mac OS X 10.6.4 (10F569)
Report Version: 6

ALLOC 0x6669130-0x6669177 [size=72]: thread_a0366500 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoObservers | __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ | CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) | CA::Transaction::commit() | CA::Context::commit_transaction(CA::Transaction*) | CALayerDisplayIfNeeded | -[CALayer display] | -[UIGroupTableViewCellBackground displayLayer:] | -[UIGroupTableViewCellBackground(UIGroupTableViewCellBackgroundInternal) _cachedImageForKey:] | doClip | CGGStateClipToPath | maybeCopyClipState | CGClipStackCreateMutableCopy | calloc | malloc_zone_calloc
----
FREE 0x6669130-0x6669177 [size=72]: thread_a0366500 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __CFRunLoopRun | __CFRunLoopDoObservers | __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ | CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) | CA::Transaction::commit() | CA::Context::commit_transaction(CA::Transaction*) | CALayerDisplayIfNeeded | -[CALayer display] | -[UIGroupTableViewCellBackground displayLayer:] | -[UIGroupTableViewCellBackground(UIGroupTableViewCellBackgroundInternal) _cachedImageForKey:] | CGContextRestoreGState | CGGStackRestore | CGGStateRelease | free

											
This entry was posted in Programming. Bookmark the permalink.