If your app crashes for strange reasons


#1

I was stumped - my DrawingFun app was crashing in some really strange ways. In one case, the BezierPath was reporting itself as an NSString, other was just bad memory access errors. Copying and pasting code from the web did not fix it.

Finally, I realized I had not checked “Use ARC” when I created the project. Argh. Turning it on fixed everything.

I’ve gotten lazy with memory errors thinking ARC “fixes all”†. The errors should have clued me in, but I was looking in the wrong place.

If you don’t have ARC turned on, this app (and probably others) misbehaves.

Cheers.

†Yes, I know, this overstates the case; but for a beginner with Cocoa, I’m hard-pressed to get head around other things and leaving ARC on for the moment frees that part of my brain up.


#2

Thanks for that hint. I’ve been perplexed.

But how should the code be written without ARC or autorelease pools? I can’t figure that out.


#3

ARC doesn’t need autorelease pools NOR will XCode let you use release or dealloc whilst ARC is enabled :slight_smile: