变量用到了关键字class

昨天遇到一个非常奇怪的错误,只要用到一个自定义的studentCell程序就奔溃,没有任何错误提示,堆栈提示,全局断点没用,跟踪调试发现用其他的cell都没问题,换成这个自定义的studentCell就奔溃了,注释掉这个初始化方法只剩这样

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

    if (self) {    

        

    }

 

    return self;

}

还是错误,整个cell其他方法全部注释,只剩这个初始化方法,并且还把这个初始化方法里面所有代码都删除,运行成功,打开界面一旦用到了这个studentCell就奔溃了 没有任何错误提示;

出去上了个洗手间,突然想起类扩展中可能用了关键字class了,果然回来就看到了显示班级的一个label定义用了关键字  @property (nonatomic, strong) UILabel *class;改成

 

@property (nonatomic, strong) UILabel *classLabel;  就一切ok,

 

 

 

 

 千万千万千万记得,不能用关键字命名变量,成员变量等

posted @ 2017-07-18 14:30  湘岳  阅读(132)  评论(0编辑  收藏  举报