The Golden Spot

I hope this helps someone who is learning about Linux and web application programming with Python, Django, and Javascript.

Monday, May 23, 2011

My UITableView crashes when scrolling and dequeueReusableCellWithIdentifier: is called, during the _second time_ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath is called ( to re-use the cell, after creation ).

I was getting a EXEC_BAD_ACCESS at dequeueReusableCellWithIdentifier:

I realized that after initializing my custom UITableViewCell, I am setting cell = [myCustomCell autorelease] when I should be using cell = [myCustomCell retain].

after customizing a UITableViewCell, call retain, not autorelease, before returning it from tableView:cellForRowAtIndexPath. I'll also mention that I am initializing my custom cell from a nib file by using [[NSBundle mainBundle] loadNibNamed:@"MyCustomCell" owner:self options:nil];

Labels: , ,