error: writable atomic property cannot pair a synthesized setter/getter with a user defined setter/getter

后端 未结 4 937
无人共我
无人共我 2020-11-29 16:53

I recently tried to compile an older Xcode project (which used to compile just fine), and now I\'m seeing a lot of errors of this form:

error: w

4条回答
  •  不知归路
    2020-11-29 17:11

    This question, among the other top hits you get from searching for "objective C custom property", are not updated with information about "setter =" or "getter =".

    So, to supply more information on this question:

    You can supply the @property call with your own method by writing

        @property(setter = MySetterMethod:, getter = MyGetterMethod)
    

    Notice the colon for the supplied setter method.

    Reference Apple documentation

    EDIT: I'm not quite sure how the new changes to Objective-C's properties (they are much more intelligent now) change the answers to this question. Perhaps it should all be marked as out of date.

提交回复
热议问题