views:

660

answers:

2

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.

+5  A: 

I find this method works well:

- (id)objectAtIndex:(NSUInteger)index
iPhoney
That's the correct method to get an object from an NSArray.
Georg
+3  A: 

You could also use an enumerator, like this:

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

while (myObject = [enumerator nextObject]) 
    {
// do something with myObject
}
Jane Sales