Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I have to retain a SEL

Tags:

objective-c

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

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

or should I retain?

-(void) setCallBack:(SEL) selectorToCall
{
    self->mSelectorToCall = [selectorToCall retain];
}
like image 679
George Avatar asked Oct 06 '11 21:10

George


1 Answers

No, the SEL type isn't an object reference, it's basically a constant string pointer. You can just assign it as in your first example.

like image 85
Ben Zotto Avatar answered Dec 04 '22 18:12

Ben Zotto