且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Modern Objective-C中覆盖setter和getter时访问生成的ivars时出错

更新时间:2022-12-10 12:00:23

如果同时覆盖setter和getter,编译器将不再为你自动创建实例变量。您可以将其添加到类实现中,如下所示:

If you override both the setter and the getter, the compiler will not automatically create the instance variable for you anymore. You can add it to your class implementation like so:

@implementation ClassName {
    ViewFrameModel *_viewFrameModel;
}
...
@end