Reputation: 29518
I'm trying to debug some code. I ran the static analyzer, and thought I fixed a memory leak, and now I get an error when I switch between two tabs. Here is my code when I switch between the 2nd tab and first tab:
if (_sortButton != nil) {
self.SortButton = nil;
NSMutableArray *barItems = [[self.MainToolbar items] mutableCopy];
[barItems removeObjectAtIndex:0];
[self.MainToolbar setItems:barItems]; // bad access here
[barItems release];
}
I keep getting the EXC_BAD_ACCESS on the self.MainToolbar setItems line. I added the NSZombieEnabled as an environment variable, set a break point at that bad access line, but I do not get anything printed to the console when either stepping after the breakpoint, hitting continue after the breakpoint, etc. Am I using this correctly? Thanks.
Upvotes: 0
Views: 615
Reputation: 8846
Please try adding a ,nil at the end of a list of objects for the NSArray.
[self.MainToolbar setItems:barItems,nil]
Upvotes: 0
Reputation: 75058
Far easier to use than NSZombieEnabled, is to use Profile
instead when running and select the NSZombie instrument.
This requires XCode4.
Upvotes: 1