• 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: Future Objective-C changes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Future Objective-C changes


  • Subject: Re: Future Objective-C changes
  • From: David Cittadini <email@hidden>
  • Date: Fri, 16 May 2003 16:49:08 +1000

That is good but what if I just want to support a Foo* and an int and nothing else? At the moment I can only do this with multiple method names, which is a bit strange as logically I actually have the same method (name) but different parameter types. It would be nice if the compiler could help in this area without all us thinkers having to come up with interesting solutions to a problem solved many years ago :-).

David.


On Friday, May 16, 2003, at 04:41 PM, Julian Barkway wrote:

With regards to method overloading, I thought it may be useful to be
able to say:

-(int)doSomethingWithFoo:(Foo*)y;
-(int)doSomethingWithFoo:(int)y;

With method overloading the compiler could resolve most of the
parameter type issues without me having to create different method
names just because the parameter type is different.

David.

But you can already use something like:

-(int)doSomethingWithFoo:(id)y;

and invoke it with:

int bar;
Foo *f;
[x doSomethingWithFoo: [NSNumber numberWithInt: bar]];
[x doSomethingWithFoo: f];

or however you want. Not as elegant, perhaps, and you lose compile-time type-checking but certainly doable.

Cheers,
Julian Barkway.
_______________________________________________
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.

  • Follow-Ups:
    • Re: Future Objective-C changes
      • From: David Burnett <email@hidden>
References: 
 >Re: Future Objective-C changes (From: Julian Barkway <email@hidden>)

  • Prev by Date: Fwd: Future Objective-C changes
  • Next by Date: Re: Future Objective-C changes
  • Previous by thread: Re: Future Objective-C changes
  • Next by thread: Re: Future Objective-C changes
  • Index(es):
    • Date
    • Thread