为什么Xcode要求在一个NSMutableArray变量名称前加下划线?
非生物
由 非生物
发布于 2014年04月26日
无人欣赏。
关键代码如下:
@interface XYZToDoListTableViewController ()
@property NSMutableArray *toDoItems;
@end
@implementation XYZToDoListTableViewController
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[_toDoItems removeObjectAtIndex: indexPath.row];
// [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
// withRowAnimation:UITableViewRowAnimationFade];
[self.tableView deleteRowsAtIndexPaths:[NSMutableArray arrayWithObject:indexPath]
withRowAnimation:UITableViewRowAnimationFade];
[self.tableView reloadData];
}
}
这里要实现一个TableView的删除功能,我在第14行写上
[toDoItems removeObjectAtIndex: indexPath.row];
Xcode会报错,并提示我改成_toDoItems。
改成了_toDoItems能实现功能,但是为什么要加下划线在下面呢?