I’ve found that in my code i release object which had never been allocated and i do not get any error. The app doesn’t crash. Everything works. I use Product -> Analyze and it tells me everything is all right.
I used to think releasing not allocated object leads to app crash. So my question is – should program crash when not allocated object is released (i.e I’ve missed something essential in my code which results in such a behavior) or everything runs as it is supposed to?
It all depends on if the pointer to the “unallocated” object is
nil. In Objective-C, a message sent tonildoes nothing. The app crash is caused by sending a message to a dangling pointer (or a garbage pointer etc).