Reputation: 399
What is the best practice, even in general programming, when you have an undefined, possibly infinite, amount of items that you need in an array but don't have defined bounds. Can you define an endless array in objective c that you can keep pushing items onto, like other lanaguages have a list item.
Thanks for any help.
Upvotes: 1
Views: 1940
Reputation: 1316
Well, your question refers to Objective-C, but if you are using the Cocoa frameworks, there is the NSMutableArray class
Use as so:
[NSMutableArray array];
[array addObject:anObject];
Check out its docs Here: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/Reference/Reference.html
Upvotes: 3
Reputation: 9543
The various Cocoa collection classes are your friends, especially NSMutableArray in this case. If you want infinite items, though, you may find you run out of time and space...
Upvotes: 0