• 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
How do I get something like performSelector:(SEL) withObjects:(NSArray *)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I get something like performSelector:(SEL) withObjects:(NSArray *)?


  • Subject: How do I get something like performSelector:(SEL) withObjects:(NSArray *)?
  • From: Christoffer Lernö <email@hidden>
  • Date: Sun, 25 Sep 2005 01:10:01 +0200

Hello everyone,

I have a small problem looking for a nice solution.

I want to dynamically call different methods on a delegate. Normally I'd use performSelector, but the method (and consequently the arguments) cannot be restricted to 0 or 1.

The arguments are all stored in an NSArray, and the selector itself is actually described in the same manner, being assembled before the call is made.

Now, the way I made this work was to create an NSInvocation, having to go by way of NSMethodDefinition etc etc. copying all the argument pointers first into a c-style array and then moving them to into NSInvocation, all the way I got a feeling I was doing the whole thing wrong.

After writing some really hideous code, I got it to work.

However, there just has to be some simpler way of doing this, or?

How do I create something efficient that would be suitable as a category to NSObject?

I was thinking it should look something along the lines of:

 -(void)performSelector:(SEL)aSelector withObjects:(NSArray *)anArray


/Christoffer _______________________________________________ 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
  • Follow-Ups:
    • Re: How do I get something like performSelector:(SEL) withObjects:(NSArray *)?
      • From: Daniel Jalkut <email@hidden>
  • Prev by Date: Re: nextKeyView and return
  • Next by Date: using zlib on OS X
  • Previous by thread: Re: Custom Palette - Cannot Decode Object error
  • Next by thread: Re: How do I get something like performSelector:(SEL) withObjects:(NSArray *)?
  • Index(es):
    • Date
    • Thread