开发者

Do I have to retain a SEL

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

-(void) setCallBack:(SEL) sel开发者_Python百科ectorToCall
{
    self->mSelectorToCall = selectorToCall;
}

or should I retain?

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


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.


No, selectors are not objects, so you can't retain them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜