• 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: Method selectors and parameter passing
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Method selectors and parameter passing


  • Subject: Re: Method selectors and parameter passing
  • From: Douglas Davidson <email@hidden>
  • Date: Mon, 9 Dec 2002 10:42:56 -0800

On Monday, December 9, 2002, at 10:17 AM, Mike Ferris wrote:

There are two ways to go here. One is simple but slightly limited, the other is general but a bit more complicated.

If the parameters are always objects or ints/chars (ie not floating point scalars or structs) and you never have more than two parameters, you can use selectors (and targets unless you always know the object to send the message to) and then use -performSelector: or -performSelector:withObject: or -performSelector:withObject:withObject: (depending on the number of parameters.)

If you need to invoke methods that do not conform to the conditions above (eg they take floats or structs or have more than two parameters) then you could store an NSInvocation and use the NSInvocation to invoke the message.

Another option would be to decide ahead of time that you were going to require all of your methods to take a single argument, which would be a property list; in some cases, it could consist of a single value, in others an array, perhaps in others a dictionary. Methods not needing arguments could simply ignore it.

Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: Method selectors and parameter passing (From: Mike Ferris <email@hidden>)

  • Prev by Date: Re: Cocoa Book
  • Next by Date: Re: Subject: Re: Cocoa Book / ok, ok.
  • Previous by thread: Re: Method selectors and parameter passing
  • Next by thread: Re: Method selectors and parameter passing
  • Index(es):
    • Date
    • Thread