views:

269

answers:

2

Background:

I'm trying out the "HelloPoly" assignment in the CS193P course. I've created my .xib file, and a custom Controller class.

I haven't fleshed out any methods - I've only allowed IB to write the class files into xcode.

Problem:

Every single time I startup the application, it bombs out. When I run gdb I see it's an EXC_BAD_ACCESS error. This means I'm accessing something non-existent in memory right? Thing is, all I have is the default files created by IB and the main. Nothing more.

I've checked posted code solutions to see what's different and I'm not sure what to try next. What do you guys usually check for when your app crashes every time on startup?

The stack trace reveals it's happening in main.m when creating UIApplicationMain - meaning I never make it to my application delegate.

Here's the trace:

Program received signal:  “EXC_BAD_ACCESS”.
(gdb) where
#0  0x01b70d45 in CFHash ()
#1  0x01b741cf in __CFDictionaryFindBuckets1b ()
#2  0x01b72b0a in CFDictionaryGetValue ()
#3  0x00450535 in -[UIProxyObject initWithCoder:] ()
#4  0x0133886e in UINibDecoderDecodeObjectForValue ()
#5  0x013398c2 in -[UINibDecoder decodeObjectForKey:] ()
#6  0x00450b35 in -[UIRuntimeConnection initWithCoder:] ()
#7  0x0045101c in -[UIRuntimeEventConnection initWithCoder:] ()
#8  0x0133886e in UINibDecoderDecodeObjectForValue ()
#9  0x0133820a in UINibDecoderDecodeObjectForValue ()
#10 0x013398c2 in -[UINibDecoder decodeObjectForKey:] ()
#11 0x0044feab in -[UINib instantiateWithOptions:owner:loadingResourcesFromBundle:] ()
#12 0x00451fcb in -[NSBundle(NSBundleAdditions) loadNibNamed:owner:options:] ()
#13 0x002910a6 in -[UIApplication _loadMainNibFile] ()
#14 0x0029a82a in -[UIApplication _runWithURL:sourceBundleID:] ()
#15 0x00297b88 in -[UIApplication handleEvent:withNewEvent:] ()
#16 0x002936d3 in -[UIApplication sendEvent:] ()
#17 0x0029a0b5 in _UIApplicationHandleEvent ()
#18 0x0239eef1 in PurpleEventCallback ()
#19 0x01bb2b80 in CFRunLoopRunSpecific ()
#20 0x01bb1c48 in CFRunLoopRunInMode ()
#21 0x00291e69 in -[UIApplication _run] ()
#22 0x0029b003 in UIApplicationMain ()
#23 0x000026a8 in main (argc=1, argv=0xbffff000) at main.m:14

I didn't see this particular problem in other threads, but please clue me in if I missed them.

Ideas?

Thanks.

+1  A: 

It's crashing in NibDecoder, i.e. when loading your XIB files. You probably have a reference in there to an object or property that doesn't exist or isn't initialized.

calmh
Ok so all the UIProxyObject and CFDictionary and CFHash calls are supporting UINibDecoder.I'm hoping I'll be able to set breaks/print the values UINibDecoder and see what it's accessing. Sometimes it's all .asm code.I'll report back when I get a chance to try this. Thanks calmh and Hoang.
madchedar0
I got desperate and began removing pieces of my nib until it stopped crashing. I removed buttons, labels, etc until it was blank.It still crashed! I just removed my "Controller" object so I just had my First Responder, Window, File's Owner and my Application Delegate. This worked!So something must have been weird with the Controller object I was using. I'm going to start from the ground up (blank view) and see what happens. Once I figure out what I did wrong I'll update this post.
madchedar0
I built everything up again from scratch in my custom controller object and i've bypassed what was killing me last time.Every single change I made I compiled and ran in the iPhone sim to make sure I didn't trip myself up. I think my connections to my Controller object must have been incorrect and I was doing something else.So lesson learned is compile and test a lot when doing IB layouts... not just when using xcode!
madchedar0
A: 

Check the name of the .xib file and the name of the initByNibName method, if they are the same. Probably, these two names are different.

sfa