Can I create properties with a public getter and private setter?

前端 未结 2 1667
孤独总比滥情好
孤独总比滥情好 2020-12-30 04:53

I\'d like to use properties for my instance variables, but in many cases, I only want the class itself to have access to the setter. I was hoping I could do something like

2条回答
  •  渐次进展
    2020-12-30 05:43

    When Barry says "the default is retain for properties" he means that retain should be specified like this:

    @property (retain) NSDate *endDate;
    

    If they are left like this:

    @property NSDate *endDate;
    

    assign is assumed by the compiler.

提交回复
热议问题