Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Property with type SEL in Objective-c

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?

like image 590
SundayMonday Avatar asked Nov 08 '11 22:11

SundayMonday


People also ask

What is SEL in Objective-C?

Defines an opaque type that represents a method selector.

What is 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.


1 Answers

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.

like image 58
Joshua Weinberg Avatar answered Sep 23 '22 14:09

Joshua Weinberg