UITableViewCell AutoRelease causing crash...?
Not sure if anyone knows if there exists a practical limit to the amount of UITableViewCells being constantly reutilized...? First of all I well aware of all the Obj-C / Apple memory management rules, (I will state this first, so I am not wasting anyones time, and they are not wasting mine)
So I will ask this straight out... is there some practical limit regarding the "Autorelease" mechanism attached to reusing UITableViewCell's..? Because I only seem to be experiencing the crash after a certain number, usually over 50 pages worth of cells (around 50 pages + 50 cells) get turned over... Then out of no-where I will get this crash.. Sometimes never happens at all, sometimes happens quite frequently, depending on content density...
Would it be better to start manually retaining and releasing on my own..? If so, would someone have the experience to recommend a good place to release them..?
[tableview tableView:cellForRowAtIndexPath:]: message sent to deallocated instance 0x14e0a920
Ok.... I failed to find anything to do with the actual UITableViewCell (Cell contents or cell itself) but after adding a few retains to the Controller (which instantiates the UITableView Object) the "crash" mysteriously stopped showing up...
Here's what I changed. Basically I added three Retain statements, which by the way, I used the original Example tutorial on "How To" - "UITabBarController" from a Self Proclaimed "Iphone Expert", but the "expert" negated to include the retains.... (this is only the applicable portion of the code...)
//initialize the UITabBarController
tabBarController = [[UITabBarController alloc] init];
TabBarControllerSet = TRUE;
//Create the first UITabBarItem
MainMessageBoard *mainMessageBoard = [[MainMessageBoard alloc] initWithController: self];
[mainMessageBoard setTitle:@"?????"];
[mainMessageBoard retain]; ////******** ADDED This RETAIN ***********
//Create the second UITabBarItem
PostNewComment *postNewComment = [[PostNewComment alloc] initWithController: self];
[postNewComment setTitle:@"????"];
[postNewComment retain]; ////******** ADDED This RETAIN ***********
//Create the third UITabBarItem
logout *Logout = [[logout alloc] initWithController: self];
[Logout setTitle:@"?????"];
[Logout retain]; ////******** ADDED This RETAIN ***********
//add the UIViewControllers to the UITabController
tabBarController.viewControllers = [NSArray arrayWithObjects:mainMessageBoard, postNewComment, Logout, nil];
[tabBarController setDelegate:self];
//release
[mainMessageBoard release];
[postNewComment release];
[Logout release];
[self.view addSubview:tabBarController.view];
AFAIK it's limited only by the memory free on device - I'm assuming that it's using some sort of dynamic set in the autorelease pool and in the table view's reusable cells (ie NSSet or a lower level equivalent).
I've used table views with tens of thousands of rows without any problem.
链接地址: http://www.djcxy.com/p/30586.html