Re: Nil-terminated object list?
Re: Nil-terminated object list?
- Subject: Re: Nil-terminated object list?
- From: Clark Cox <email@hidden>
- Date: Mon, 19 Jul 2004 13:12:49 -0400
On 7 19, 2004, at 12:41, Nick Zitzmann wrote:
>
Here's something I've been wondering about that I haven't seen
>
discussed in the archives...
>
>
How does one make a method that takes a nil-terminated object list as
>
an argument, like NSArray's +arrayWithObjects: and NSDictionary's
>
+dictionaryWithObjectsAndKeys: methods?
>
>
Situation: I'd like to write an instance method in an NSMutableArray
>
category that adds a nil-terminated object list to an existing
>
NSMutableArray, but I can't find any documentation or examples on how
>
to do this. I've searched and found some marg methods in the
>
Objective-C runtime, but I can't figure out how to use them... Does
>
anyone know how to do this, and if so, how?
>
Something like this (warning, composed in Mail):
#import <stdarg.h>
-(void)myMethod:(id)firstArg, ...
{
va_list args;
va_start(args, firstArg);
for(id nextArg = firstArg; nextArg != nil; nextArg = va_arg(args, id))
{
//Do something with nextArg
}
va_end(args);
}
do a "man stdarg" for more information
--
Clark S. Cox III
email@hidden
http://www.livejournal.com/users/clarkcox3/
http://homepage.mac.com/clarkcox3/
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.