EXC_BAD_ACCESS Mystery
I could use a little help on this one. I narrowed the crash source down to NSMutableArray viewControllers by commenting out the release statement in dealloc.
Code:
NSMutableArray *controllers = [[NSMutableArray alloc] init];
for (NSInteger i = 0; i < self.numSlides; i++) {
[controllers addObject:[NSNull null]];
}
self.viewControllers = controllers;
[controllers release];
// Later on in dealloc:
[viewControllers release], viewControllers = nil;
In the main.m file [ int retVal = UIApplicationMain(argc, argv, nil, nil); ] we get: Program received signal: "EXC_BAD_ACCESS"
When I comment out the release for viewControllers -> no crash but memory leak.
Are you out there Obi-Wan - you are our last hope.
开发者_开发问答Thanks in advance for the help.
The code you posted looks fine; without seeing any of the rest of it, I’d guess that your viewControllers
property is declared as assign
rather than retain
. If that isn’t it, try running the static analyzer (Product > Analyze or Cmd-Shift-B); it can usually catch that kind of problem.
精彩评论