0

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 Answer 1

1

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]);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.