iOS - EXC糟糕的访问,以前在iOS 4上运行

时间:2011-11-05 21:39:25

标签: iphone ios uitableview exc-bad-access

除非我不在意,否则这在iOS4上运行正常。我更新到iOS5,现在它在[indexPath section]上抛出了这个错误的访问错误。它位于UITableView

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{    
    // Get the cell label and value
    NSLog(@"section: %@", [indexPath section]); /* BAD ACCESS ERROR HERE */
...

1 个答案:

答案 0 :(得分:4)

日志语句本身导致错误。

NSLog(@"section: %@", [indexPath section]); /* BAD ACCESS ERROR HERE */

您正在尝试记录一个整数,就好像它是一个对象一样。它应该是:

NSLog(@"section: %i", [indexPath section]);