Friday, 15 January 2010

xcode - How do I debug EXC_BAD_ACCESS code=2 while using ARC -



xcode - How do I debug EXC_BAD_ACCESS code=2 while using ARC -

i see alot of threads on here how solve exc_bad_access code=2, , consensus seems trying access array, or object in array after have released it. see of time solutions seems 1 has many [release theobject] in code. problem me don't have release calls, because using arc.

so question how go debugging myself point. can post code if help, think first step, i'd help on next step should , how it.

i have found lot of threads seem should turn on nszombiesenabled help find source of problem.

before zombies enabled app build , run absolutely no error or warnings. touch button in simulator crash.

after turning on zombies, app still builds , runs no errors, crashes simulator appears, , xcode switches debug navigator under tread 1 there listed on 100,000 entries , each 1 click on shows stuff in main window, don't know means.

so, do? have turned on zombies, , run again, see bunch of stuff in screen, don't know how create heads or tails of it. tried post screen shot, don't have authorization yet.

i looked through source code , found problem. you're trying set numberofmatchingcards property on self.game while you're in middle of lazily loading game, creating infinite loop. self.game.numberofmatchingcards going seek load new game since haven't finished instantiating game time setter called. change

- (ibaction)cardmodechanged:(uisegmentedcontrol *)sender { switch ([sender selectedsegmentindex]) { case 0: self.game.numberofmatchingcards = 2; break; case 1: self.game.numberofmatchingcards = 3; break; default: self.game.numberofmatchingcards = 2; break; } }

to

- (ibaction)cardmodechanged:(uisegmentedcontrol *)sender { switch ([sender selectedsegmentindex]) { case 0: _game.numberofmatchingcards = 2; break; case 1: _game.numberofmatchingcards = 3; break; default: _game.numberofmatchingcards = 2; break; } }

i'm not sure solve bad access issue, it's cause of many entries in debug navigator. allow me know if still have bad access issue after fixing this. it's of import remember though you're using arc, objects still released (when reference counts drop zero).

xcode ios6

No comments:

Post a Comment