I'd like to declare a property with type SEL
like this:
@property (nonatomic, assign) SEL mySelector;
Is "assign
" correct here? Perhaps assign
can be omitted?
Defines an opaque type that represents a method selector.
A selector is an identifier which represents the name of a method. It is not related to any specific class or method, and can be used to describe a method of any class, whether it is a class or instance method. Simply, a selector is like a key in a dictionary.
assign is the correct annotation here. You use assign for any primitive types. The alternatives (weak, strong/retain) rely on the property pointing at an object to function. I believe the compiler won't even let you declare the wrong type of property for this. If you really wanted to you could omit the assign as it is the default.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With