search

Home  >  Q&A  >  body text

Objective-c - What does the syntax getter assignment syntax mean when defining properties in iOS?

When defining properties on iOS @property (assign, nonatomic, getter=isDidSelected) BOOL didSelected; What does getter=isDidSelected mean? After the Demo I downloaded was written like this, the attribute isDidSelected was no longer defined.

漂亮男人漂亮男人2759 days ago731

reply all(1)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-05-16 13:21:04

    To put it bluntly, it’s just to change the name of the get method

    If you don’t write getter=isDidSelected, then the get method of Boolean value didSelected is didSelected. You can

    - (BOOL) didSelected { 
    return didSelected; 
    }
    

    Come and rewrite it. Use together

    self. didSelected
    

    Come and get it.
    If you write getter=isDidSelected, then the get method of Boolean value didSelected is isDidSelected. You can

    - (BOOL) isDidSelected { 
    return didSelected; 
    }
    

    Come and rewrite it. Use together

    self. isDidSelected
    

    Come and get it.

    reply
    0
  • Cancelreply