• 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: Objective-C default arguments??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Objective-C default arguments??


  • Subject: Re: Objective-C default arguments??
  • From: Malcolm Sharman <email@hidden>
  • Date: Sat, 01 Nov 2003 17:18:35 +1000

I just realised that I'm thinking in C++ rather than plain C, so it that
regard it won't work.

I also realised that there is a way to do what I want to do nearly as
easily.

Instead of -(void)initWithFile:(NSString *)path=@""
setmovie:(BOOL)setMovie=NO;

I use
-(void)initWithFile:(NSString *)path setMovie:(BOOL)setMovie
And
-(void)initWithFile:(NSString *)path
{
[self initWithFile:path setMovie:NO];
}

It is kind of a hack, but it works.

Malcolm


on 2003-11-01 04:51 PM, Malcolm Sharman at email@hidden wrote:

> Hi
>
> I'm reasonably new to Objective-C and cocoa and I'm trying to make a simple
> instance method of a class that takes a number of arguments.
>
> -(void)initWithFile:(NSString *)path=@"" :(BOOL)setMovie=NO;
>
> The above line of code is what I'm trying to do similar to what I can do in
> plain c
> void doSomething(int num1 = 1, int num2 = 2);
>
> Am I way off track?? Do I have to use a variable argument list in Objective-C
> to do the same thing??
>
> I can probably get around this if I can't use default arguments by using two
> methods, but it would be nicer to do it this way
> Thanks for any help
>
> Malcolm
_______________________________________________
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: Objective-C default arguments??
      • From: Clark Cox <email@hidden>
    • Re: Objective-C default arguments??
      • From: Sherm Pendley <email@hidden>
References: 
 >Objective-C default arguments?? (From: Malcolm Sharman <email@hidden>)

  • Prev by Date: Objective-C default arguments??
  • Next by Date: Re: Objective-C default arguments??
  • Previous by thread: Objective-C default arguments??
  • Next by thread: Re: Objective-C default arguments??
  • Index(es):
    • Date
    • Thread