This critical error only occurs once every 10 or so runs in the simulator, so it is very hard to debug. I was getting some kind of malloc error when my tableView was loading content from the app launch. I enabled nszombies and when the error finally reoccured I got this output:
objc[71060]: Class _NSZombie__UITableViewSeparatorView is implemented in both ?? and ??. One of the two will be used. Which one is undefined.
2011-09-14 11:01:46.080 My_App[71060:7307] *** -[_UITableViewSeparatorView release]: message sent to deallocated instance 0x4e398e0
I first noticed this error occurring after I added this code to the tableView (the first screen the user sees when the app launches)
- (CGFloat开发者_如何学Go)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath
{
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
return 90;
else
return 50;
}
The point of this code was to (obviously) define different row heights for the table in the iPad and iPhone targets respectively.
Is the problem in this section of the code?
Well, this is the worst sort of error (that only repeats sometimes). Well, the best advice I could give you would be to NSLog a lot. It sounds like an unhelpful piece of advice, but using NSLog excessively really helps me debug this sort of error.
The best way is to change your code with two constants You can just add this two lines at beginning of your .m file
#define isAniPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define HEIGHT_ROW (isAniPad ? 90.0 : 50.0)
After this just call
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath
{
return HEIGHT_ROW;
}
精彩评论