Question

I want to pull out a string from an array by index.

e.g array with object: @"Hello", @"World"

How to get @"World" from it? I use array[1], but it seems not work.

Was it helpful?

Solution

I find this method works well:

- (id)objectAtIndex:(NSUInteger)index

OTHER TIPS

You could also use an enumerator, like this:

NSEnumerator* enumerator = [myArray objectEnumerator];
ArrayObject* myObject;

while (myObject = [enumerator nextObject]) 
    {
// do something with myObject
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top