Arc and performSelector
Arc and performSelector
- Subject: Arc and performSelector
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Sun, 16 Oct 2011 14:23:17 +0700
I have this code:
for( id aThing in someArray )
{
if ( [ aThing respondsToSelector: @selector(setTitle:) ] )
{
[ self replaceIn: aThing
readSelector: @selector(title)
writeSelector: @selector(setTitle:)
withTable: tableName
];
}
}
- (void)replaceIn: thing readSelector: (SEL)selectorIn writeSelector: (SEL)selectorOut withTable: (NSString *)tableName;
{
NSString *key = [ thing performSelector: selectorIn ];
...
NSString *rep = ...
[ thing performSelector: selectorOut withObject: rep ];
}
Now, using Arc I am told that "PerformSelector may cause a leak because its selector is unknown".
What I am supposed to do about this? I really want to have code without warnings.
Update:
I guess Arc has no way to know, whether "selectorIn" is something like "copy".
So I am quite willing to reassure it that "selectorIn" is always something like title, stringValue, toolTip, etc.
I think I should declare the SEL as __attribute__((ns_returns_not_retained)).
But how exactly? There really should be some examples.
Gerriet.
_______________________________________________
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