Re: Variable Number of Parameters in Method

2013-08-22 Thread Lee Ann Rucker
On Aug 21, 2013, at 11:37 PM, Dave wrote: > Hi, > > It's not much good to me since I don't have a problem passing objects but > with passing a mixed set. > > Type passing, 1,2,3,5.6,@"hello",nil to the arrayWithObjects and you will see > what I mean > > Cheers > Dave But 1,2,3 etc aren't ob

Re: Variable Number of Parameters in Method

2013-08-22 Thread Maxthon Chan
This is actually an ABI issue. Objective-C method calls are essentially C function calls: [NSArray arrayWithObjects:@1, @2, @3, nil]; is really (C function symbol name is guessed from a common name mangling scheme) __objc_c_NSArray_arrayWithObjects_([NSArray class], @selector(arrayWithObjects:

Re: Variable Number of Parameters in Method

2013-08-21 Thread Dave
Hi, It's not much good to me since I don't have a problem passing objects but with passing a mixed set. Type passing, 1,2,3,5.6,@"hello",nil to the arrayWithObjects and you will see what I mean Cheers Dave On 21 Aug 2013, at 20:04, Alex Zavatone wrote: > Just in case the styled text is str

Re: Variable Number of Parameters in Method

2013-08-21 Thread Alex Zavatone
Just in case the styled text is stripped, here is the line I'm referring to from the header file: + (id)arrayWithObjects:(id)firstObj, ... NS_REQUIRES_NIL_TERMINATION; Sent from my iPad On Aug 21, 2013, at 2:58 PM, Alex Zavatone wrote: > The approach I mentioned is what NSArray uses to allow

Re: Variable Number of Parameters in Method

2013-08-21 Thread Alex Zavatone
The approach I mentioned is what NSArray uses to allow an arbitrary amount of objects in this call to init it. Supplying nil tells the runtime that there are no more parameters. NSArray *myArray; myArray = [NSArray alloc] initWithObjects: @"my String", @"another", @"more", nil]; It's the nil

Re: Variable Number of Parameters in Method

2013-08-21 Thread Stephen J. Butler
On Wed, Aug 21, 2013 at 4:22 AM, Dave wrote: > if ([myType isEqualToString:@"NSInteger"] ) > { > myNSInteger = va_arg(myArgumentList,NSInteger*); > // do something with myNSInteger > [myFormattedString appendFormat:@"myNSInteger = %d ", > m

Re: Variable Number of Parameters in Method

2013-08-21 Thread Keary Suska
On Aug 21, 2013, at 3:22 AM, Dave wrote: > Sorry that snippet was from an existing method that used a nil terminated > list, you're right, I can't do that in this case. > > I was thinking that it would be easier if everything was an Object, the types > I need to support are: > > id

Re: Variable Number of Parameters in Method

2013-08-21 Thread Alex Zavatone
I copied and pasted that code from the iOS NSArray.h file. The example you want is in bold. On Aug 21, 2013, at 9:39 AM, Scott Ribe wrote: > On Aug 21, 2013, at 5:29 AM, Alex Zavatone wrote: > >> However, this does: >> >> @interface NSArray (NSArrayCreation) > > ? That method has both common

Re: Variable Number of Parameters in Method

2013-08-21 Thread Scott Ribe
On Aug 21, 2013, at 5:29 AM, Alex Zavatone wrote: > However, this does: > > @interface NSArray (NSArrayCreation) ? That method has both common base types and a nil terminator. -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice _

Re: Variable Number of Parameters in Method

2013-08-21 Thread Alex Zavatone
However, this does: @interface NSArray (NSArrayCreation) + (id)array; + (id)arrayWithObject:(id)anObject; + (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt; + (id)arrayWithObjects:(id)firstObj, ... NS_REQUIRES_NIL_TERMINATION; arrayWithObjects: Creates and returns an array conta

Re: Variable Number of Parameters in Method

2013-08-21 Thread Dave
Hi, Sorry that snippet was from an existing method that used a nil terminated list, you're right, I can't do that in this case. I was thinking that it would be easier if everything was an Object, the types I need to support are: id Numeric types, signed/un

Re: Variable Number of Parameters in Method

2013-08-21 Thread Stephen J. Butler
On Wed, Aug 21, 2013 at 2:35 AM, Dave wrote: > -(void) methodX:(NSString*) theName,… > { > va_list > myArgumentList; > NSInteger > myArgumentCount; > > myArgumentCount = 0; > va_start(myArgumentList,theMethodName); > > while(va_arg(myArgumentList,NSString*) != nil) > // >