开发者

EXC_BAD_ACCESS upon simple iPhone app startup

开发者 https://www.devze.com 2022-12-19 23:24 出处:网络
Background: I\'m trying out the \"HelloPoly\" assignment in the CS193P course. I\'ve created my .xib file, and a custom Controller class.

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.


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.


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.


I just solved this for a similarly basic iPhone app in a teach-yourself book, and realized that I had simply misplaced an @ after a " instead of in front - Meow is the one that's messed up (below) and that was enough to throw the error:

animalSounds=[[NSArray alloc]initWithObjects: @"Oink","@Rawr",@"Ssss",@"Roof","@Meow",@"Honk",@"Squeak",nil];

To debug I used the super basic method of setting breakpoints and NSLog output, so I could figure out which of the 4 variables I was using was screwed up.

0

精彩评论

暂无评论...
验证码 换一张
取 消