Why I got a "sent to freed object error"?

Posted by Tattat on Stack Overflow See other posts from Stack Overflow or by Tattat
Published on 2010-05-02T06:05:54Z Indexed on 2010/05/02 6:07 UTC
Read the original article Hit count: 340

I have a Table View, and CharTableController, the CharTableController works like this:

.h:

#import <Foundation/Foundation.h>


@interface CharTableController : UITableViewController <UITableViewDelegate, UITableViewDataSource>{
//  IBOutlet UILabel *debugLabel;
    NSArray *listData;
}
//@property (nonatomic, retain) IBOutlet UILabel *debugLabel;
@property (nonatomic, retain) NSArray *listData;


@end

The .m:

#import "CharTableController.h"

@implementation CharTableController
@synthesize listData;

- (void)viewDidLoad {
    NSArray *array = [[NSArray alloc] initWithObjects:@"Sleepy", @"Sneezy", @"Bashful", @"Happy", @"Doc", @"Grumpy", @"Dopey", @"Thorin", @"Dorin", @"Nori", @"Ori", @"Balin", @"Dwalin", @"Fili", @"Kili", @"Oin", @"Gloin", @"Bifur", @"Bofur", @"Bombur", nil];
    self.listData = array; 
    [array release]; 

    [super viewDidLoad];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return [self.listData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier];

    if (cell == nil) { 
        cell = [[[UITableViewCell alloc]
            initWithStyle:UITableViewCellStyleDefault 
            reuseIdentifier:SimpleTableIdentifier] autorelease];

        NSUInteger row = [indexPath row]; cell.textLabel.text = [listData objectAtIndex:row]; 
    }
    return cell;
}

@end

And I Use the IB to link the TableView's dataSource and delegate to the CharTableController. In the CharTableController's view is the TableView in IB obviously. Reference Object in dataSource > TableView and delegate > TableView. What's wrong with my setting? thz.

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about iphone-sdk-3.0