Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Soulstorm

macrumors 68000
Original poster
Feb 1, 2005
1,887
1
In my program I have a problem.

I want to be able to make an NSMutable array that accepts as many arguments as I want, and I want to be able to insert a 'nil' at its end.

Is that possible?
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
why do you want to do this? You can ask an array for it's length, so you don't need a special element to tell you you're at the end.

-Lee
 

Soulstorm

macrumors 68000
Original poster
Feb 1, 2005
1,887
1
Use an NSNull
From Apple docs:
The NSNull instance is semantically equivalent to nil, however it is also important to appreciate that it is not equal to nil.

why do you want to do this? You can ask an array for it's length, so you don't need a special element to tell you you're at the end.

-Lee

I am building an extension to an existing library for which I don't have the original source. Inside that library, there is a class that has a function that accepts variable arguments, with nil at the end.
 

eddietr

macrumors 6502a
Oct 29, 2006
807
0
Virginia
I am building an extension to an existing library for which I don't have the original source. Inside that library, there is a class that has a function that accepts variable arguments, with nil at the end.

Well, that function doesn't accept an NSArray then, right?

So I would add the terminating nil when you actually call that function (in other words, when you construct the list for that function). Maybe add a category to NSArray with a method that returns this arg list null terminated for you.

Unless I'm not understanding what you are trying to do?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.