为什么这个TableView代码有效?

nev*_*ing 1 iphone objective-c uitableview

UITableViewCell用这段代码创建了一个拼写错误:

- (UITableViewCell *)tableView:(UITableView *)tableView
         cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"CellIdentifier";
    UITableViewCell *cell = [self.tableView
        dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        NSLog(@"Creating cell");
        cell = [[[UITableViewCell alloc] 
            initWithStyle:UITableViewStylePlain
            reuseIdentifier:CellIdentifier] autorelease];
    }
    cell.textLabel.text = @"Hello";
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

错字是用UITableViewStylePlain而不是UITableViewCellStyleDefault.代码工作正常,创建新单元格.为什么?

kub*_*ubi 10

这就是定义这些变量的方式.

typedef enum {
   UITableViewCellStyleDefault,
   UITableViewCellStyleValue1,
   UITableViewCellStyleValue2,
   UITableViewCellStyleSubtitle
} UITableViewCellStyle;

typedef enum {
   UITableViewStylePlain,
   UITableViewStyleGrouped
} UITableViewStyle;
Run Code Online (Sandbox Code Playgroud)

双方UITableViewCellStyleDefaultUITableViewStylePlain评估为0,所以他们互换.