oc实例变量的访问方式

-(void)setName:(NSString *)name andAge:(NSInteger)age{
    //实例变量的访问方式
    //1.直接访问
    _name = name;
    _age = age;
    
    //2.间接访问,set方法
    [self setName:name];
    [self setAge:age];
    
    //3.通过self指针直接访问
    self->_name = name;
    self->_age = age;
}

你可能感兴趣的:(oc实例变量的访问方式)