In didFinishLaunchingWithOptions, the first code is:
NSMutableArray *k = [[NSMutableArray alloc] initWithCapacity:10];
[k release];
(I reduced it to this case after much debugging) and I'm getting
*** -[__NSArrayM class]: message sent to deallocated instance 0x7576c90
*** -[__NSArrayM respondsToSelector:]: message sent to deallocated instance 0x7576c90
If I check the retainCount on 'k' after the alloc line, it is 1. If I replace NSMutableArray by NSArray everything is fine. What the heck is going on here??
That error must be coming from somewhere else. Which means you're using it. Else, you wouldn't have
*** -[__NSArrayM respondsToSelector:]: message sent to deallocated instance 0x7576c90
But something like :
*** -[__NSArrayM release]: message sent to deallocated instance 0x7576c90
Plus, you should not use retainCount (see why here).
Just check that you're not using it anywhere else. Or maybe you're using ARC ? In which case you don't need to release it.