Zombie Messaged In For Loop
I have an ivar, keys
which is an NSMutableArray containing 50 strings. When开发者_开发问答 my view loads, i am getting a zombie messaged error in Instruments, and it is directing me to this line of code:
for (int row = 0; row < r; row++) {
for (int column = 0; column < c; column++){
otherArray[column][row] = [[[keys objectAtIndex:0] retain] autorelease];
//^ Instruments brings me here
[keys removeObjectAtIndex:0];
}
}
I have retained the value to keep it alive so that the remove
will not cause a crash, but it still does. I have tried not retaining, and autoreleasing and it still crashes. This method of retaining and autoreleasing works when i have a local variable, but not an ivar...
I need an ivar because i need to access the strings elsewhere.
Thanks
synthesize it and release and it in your dealloc.
Solved -- Memory management problem - keys was not being correctly retained.
精彩评论