Property with type SEL in Objective-c

Objective CPropertiesSelector

Objective C Problem Overview


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?

Objective C Solutions


Solution 1 - Objective C

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSundayMondayView Question on Stackoverflow
Solution 1 - Objective CJoshua WeinbergView Answer on Stackoverflow