• 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: variable arguments in ObjC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: variable arguments in ObjC


  • Subject: RE: variable arguments in ObjC
  • From: "Eric Ridge" <email@hidden>
  • Date: Fri, 22 Feb 2002 12:34:44 -0500
  • Thread-topic: variable arguments in ObjC

> Now I've got this thing almost working, but I'm losing the
> first argument.
> Any ideas where it's gone?

The va_arg macro expands to an expression that has the type and value of
the _next_ argument in the call. Check the man page for va_arg.

>
> [[Something alloc] initWith:@"one", @"two", @"three",
> @"four", @"five",
> nil]
>
> - (id)initWith:(id)item, ...
> {
> va_list list;
> va_start( list, item );

So, with your code, the "item" argument has the value of @"one". The
va_arg list starts at the next value (in this case @"two").

Typically, when using vaargs, the first argument to the method is a
format (a la xprintf), and the remaining arguments are the actual
values.

<snip>

> va_list started
> arg processed two
> arg processed three
> arg processed four
> arg processed five
> va_list ended
>
>
> what happened to number 1?

again, @"one" is in the variable "item".

eric
_______________________________________________
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: variable arguments in ObjC
      • From: Nicholas Shanks <email@hidden>
  • Prev by Date: Re: variable arguments in ObjC
  • Next by Date: Re: variable arguments in ObjC
  • Previous by thread: Re: variable arguments in ObjC
  • Next by thread: Re: variable arguments in ObjC
  • Index(es):
    • Date
    • Thread