我得到'row'错误的Redifinition,并且'setText'已被弃用错误..我不知道如何修复它。这是代码

时间:2011-03-03 02:34:54

标签: ios4 uitableview

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }

    // Set up the cell...
    NSUInteger row = [indexPath row];{
    cell.text = [capitulosArray objectAtIndex:row];

    return cell;
    }

    NSUInteger row = [indexPath row];{
    cell.text = [capitulos2Array objectAtIndex:row];

    return cell;
    }
}

我来这里学习

1 个答案:

答案 0 :(得分:0)

您似乎认为NSUInteger row = [indexPath row];{ ... }类似于C#的using。它不是,它就像C中的类似构造一样。所以你要声明局部变量“row”两次,编译器会警告你。

对于不推荐使用“setText”的警告,那是因为它是。见the documentation。您很可能希望改为使用cell.textLabel.text