How to override @synthesized getters?

前端 未结 4 505
逝去的感伤
逝去的感伤 2020-12-24 00:11

how to override a property synthesized getter?

4条回答
  •  心在旅途
    2020-12-24 00:57

    I just want to add, I was not able to override BOOL property with getter/setter, until I add this :

    @synthesize myBoolProperty = _myBoolProperty;
    

    so the complete code is :

    in header file :

    @property  BOOL myBoolProperty;
    

    in implementation file :

    @synthesize myBoolProperty = _myBoolProperty;
    
    
    -(void)setMyBoolProperty:(BOOL) myBoolPropertyNewValue
    {
        _myBoolProperty = myBoolPropertyNewValue;
    }
    
    -(BOOL) myBoolProperty
    {
        return _myBoolProperty;
    }
    

提交回复
热议问题