I have a problem in the following two code lines
NSDictionary* last = [[arrHistory lastObject] autorelease];
[arrHistory removeLastObject];
In the debugger I can see that, after the first code line has been executed, last points to a dictionary with value pairs (as it should).
The problem is the second code line. It seams to destroy the content of the dictionary. I thought the autorelease on line 1 would solve the problem but, it dod not.
The
arrHistoryowns its members, you shouldn’t callrelease / autoreleaseof its member that you don’t own before you taking its ownership.If you want to use the last object after removing, you can do it like this:
NSDictionary* last = [[arrHistory lastObject] retain] autorelease];