views:

119

answers:

1

I have the following code

NSMutableArray *leeTemp = [[NSMutableArray alloc] init];
Player* playerLee = [[Player alloc] init];
playerLee.name = [array objectAtIndex:1];
[leeTemp addObject:playerLee];
[playerLee release];

And this generates an array of Players (I think)! When I do the following it shows the addresses of the Players.

NSLog(@"%@",leeTemp);

What I am struggling with is retreiving say array[0].name, this is a string value. I'm sure this is very simple but am struggling to visualise this.

+1  A: 

You want to do:

NSLog(@"%@", [[leeTemp objectAtIndex:0] name]);

Or if you want to loop through an array you can use for..in iteration:

for (Player *player in leeTemp) {
  NSLog(@"%@", [player name]);
}
Louis Gerbarg
Just what I was after, thanks!Both methods work great.
Lee Armstrong