Xref: utzoo comp.sys.next:8659 comp.lang.objective-c:40 Path: utzoo!attcan!uunet!know!zaphod.mps.ohio-state.edu!wuarchive!sdd.hp.com!ucsd!network.ucsd.edu!weber.ucsd.edu!pbiron From: pbiron@weber.ucsd.edu (Paul Biron) Newsgroups: comp.sys.next,comp.lang.objective-c Subject: Re: methods with arbitrary # of args? How? Message-ID: <3875@network.ucsd.edu> Date: 16 Oct 90 17:22:16 GMT Sender: news@network.ucsd.edu Reply-To: pbiron@weber.ucsd.edu (Paul Biron) Followup-To: comp.sys.next Organization: Division of Social Sciences, UCSD Lines: 40 Nntp-Posting-Host: weber.ucsd.edu In <3860@network.ucsd.edu>, pbiron@weber.ucsd.edu (Paul Biron) writes: >Is it possible to define an obj-c method which takes an >arbitrary number of arguments (ala normal C functions >which use varargs.h)? The net comes through again, thanx to those who responded!!! The "answer" is, (from NeXT manuals, Chap 3, p 12): Methods that take a varaible number of arguments declare them just as a function would. - makeGroup:group,... ; That's it! No mention of how to call them though!!!! However, in Chap 22, p 31 (the Spec sheet for Object), there's an example call of Objects error: method which is a vararg method (sorry, I forgot to write down the call, but it went something like this): - error:(STR)str,... ; [self error:"index %d is greater than max %d\n", index, max] ; IOW, the _method_ only has 1 argument, but that 1 argument is made up of comma separated "arguments". Note that the same kinds of restrictions that apply to the use of varargs.h, apply here. I have also been told there is an example of this in Issue 9 of the _NeXT User's Journal_, in the Buzz Hints section. Thanx again to those who pointed me in the right direction! Paul Biron pbiron@ucsd.edu (619) 534-5758 Central University Library, Mail Code C-075-R Social Sciences DataBase Project University of California, San Diego, La Jolla, Ca. 92093