Should I keep SEL

When I get a selector passed to my method, should I just save it:

-(void) setCallBack:(SEL) selectorToCall { self->mSelectorToCall = selectorToCall; } 

or should i save?

 -(void) setCallBack:(SEL) selectorToCall { self->mSelectorToCall = [selectorToCall retain]; } 
+6
source share
2 answers

No, the SEL type is not an object reference, it is basically a constant pointer to a string. You can simply assign it, as in the first example.

+8
source

No, selectors are not objects, so you cannot save them.

+5
source

Source: https://habr.com/ru/post/898799/


All Articles