Re: Arc and performSelector
Re: Arc and performSelector
- Subject: Re: Arc and performSelector
- From: David Duncan <email@hidden>
- Date: Mon, 17 Oct 2011 10:26:40 -0700
On Oct 17, 2011, at 10:19 AM, Gerriet M. Denkmann wrote:
> I understand this. So I tried to tell the compiler that the passed selector is not like copy:
>
> - (void)replaceIn: thing readSelector: (__attribute__((ns_returns_not_retained)) SEL)selectorIn
> {
> NSString *key = [ thing performSelector: selectorIn ];
> }
>
> But it still complains: "PerformSelector may cause a leak because its selector is unknown".
> Sure, it is unknown, but it's non-retaining behaviour is known.
The attribute you added is not applicable here, so it is ignored (the attribute must be added to a function or method declaration, where as a SEL is just a data type). Consider also that you can't declare such a thing universally for all SEL – it is the underlying method on a particular class that has the behavior you are looking for.
> Is this a bug?
No, its the compiler admitting that it has no way to verify that what is happening will have the behavior you expect. Thats why this is a warning and not an error.
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden