I have following code, which executes on button press. At first it works as expected but second time onwards application hangs and I get EXC_BAD_ACCESS signal.
- (IBAction) comicDetailsPressed:(id)sender {
static IssueProperties *props = nil;
if (props == nil) {
props = [ComicDataParser
parseComicForUrl:@"http://dummy.com/Jan.xml"];
}
NSLog(@"%d", [props totalPages]);
totalPages.text = [NSString stringWithFormat:@"%d", [props totalPages]];
}
You didn’t say what line it’s crashing on, which will mean answers will have to be speculative.
You have a static pointer to a
IssuePropertiesobject, but when you assign to it, you aren’t usingretain. You probably should.This is assuming that the return value from
parseComicForUrl:is aIssuePropertiesobject or a subclass.I’m assuming that the
textproperty is anNSStringset tocopyand notretain. If not, it should be.