UITableView titleForHeaderInSection prints headers to console twice then crashes

Posted by joec on Stack Overflow See other posts from Stack Overflow or by joec
Published on 2010-03-30T20:34:02Z Indexed on 2010/03/31 3:13 UTC
Read the original article Hit count: 435

In the method below titleForHeaderInSection, for some reason the NSLog prints out the headers twice and then the app crashes in objc_msgSend. I can't understand why this would cause the app to crash?

It would seem from research that crashes in objc_msgSend are caused by sending messages to already freed objects, but is that the case here?

My sectionNames array is populated in viewDidLoad.

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {   

    NSString *title = nil;
    title=[sectionNames objectAtIndex:section];
    NSLog(title);
    return title;
}

Thanks

© Stack Overflow or respective owner

Related posts about uitableview

Related posts about objective-c