• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: selectors in NSDictionaries?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
References: 
 >Fwd: selectors in NSDictionaries? (From: Azza <email@hidden>)

  • Prev by Date: Re: selectors in NSDictionaries?
  • Next by Date: Library problem when deployed
  • Previous by thread: Re: selectors in NSDictionaries?
  • Next by thread: Library problem when deployed
  • Index(es):
    • Date
    • Thread