Re: selectors in NSDictionaries?
Re: selectors in NSDictionaries?
- Subject: Re: selectors in NSDictionaries?
- From: Ondra Cada <email@hidden>
- Date: Fri, 7 Apr 2006 02:00:48 +0200
Azza,
On 7.4.2006, at 1:37, Azza wrote:
do you know if it is possible to save a selector reference i.e
@selector(someFunction:) inside a NSDictionary
Yup, possible it is...
like this?
... but not like this:
[tempDict setObject:@selector(someFunction:) forKey:@"Loader"];
As setObject implies, you have to set, well, an object (which a
selector happens not to be: it's just a plain pointer to some runtime
structure).
The best solution is to wrap it in an NSValue (see valueWithPointer:
and pointerValue).
If you store the dictionary content or send it to another process,
you would want to save selectors as strings instead (see
NSStringFromSelector, NSSelectorFromString): it is considerably less
efficient, though.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden