I’m having an issue when calling removeFromSuperview in a View object. The allocation history (according to instruments) is the following:
myView alloc -> myView 1
addSubview:myview -> myView 2
myView release -> myView 1
myView removeFromSuperview -> myView 0
myView dealloc -> myView -1 (invoked by removeFromSuperview)
I understand that the dealloc method is called because the reference count reaches 0. However, I don’t understand why it decreases the reference count by one, causing the message being sent to deallocated method.
Also, I can only detect it using instruments. Using xcode it doesn’t crash.
Any help would be very much appreciated.
Thanks very much.
Another really easy way to find reference count issues with Xcode is to use Analyze, the compiler is now smart enough to implement automatic reference counting, so it is also smart enough to find problems with reference counting.