Question

I've been trying to maintain a list of all the error messages I ever encounter while developing and their common causes and fixes. What are the common (and the not so common) error messages you encountered and how did you fix them?

Was it helpful?

Solution

EXC_BAD_ACCESS when referencing a pointer that points to an object that has been dealloc'ed

OTHER TIPS

In general I find objective-c exception and error messages tO be self-explanatory. I think you would be better served by learning to use the debugger with breakpoints on objective-c exceptions to locate the specific line causing a crash than by trying to compile a list of recipies for resolving common errors.

That said the one non-obvious error I see as a frequent point of confusion is "unrecognized selector foo: sent to BarClass". While the reason why that is an error should be clear answering how that happened can be harder and I see two common causes:

  1. An app is attempting to call a subclass' method on an instance of a super class. Often a result of developers failing to change the class of objects in IB.
  2. An object has been over-released or otherwise referenced after being deallocated. If a new instance of some other class now occupies that memory address the app with hit an "unrecognized selector" exception rather than a "BAD_ACCESS".
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top