Good practice for disambiguating argument names versus instance variable names in Objective-C

前端 未结 3 1811
花落未央
花落未央 2021-01-13 00:57

I run into a fairly common scenario in Objective-C where I pass in a variable to an init method and then want to assign it to an instance variable of the same name. However

3条回答
  •  一向
    一向 (楼主)
    2021-01-13 01:35

    If you use only 1 the compiler will give you a warning.

    You can combine 1 & 2 by using :

    @synthesize value = _value;
    

    If you want to hide your variable from the inheritors you can declare a empty named category and declare your property there.

    For 3 you can use aValue for your argument.

提交回复
热议问题