0

My json data could have any number of objects from a database. This all comes in fine and sends the number to objective-c in gameCount. From there I want the objectForKey to loop until it reaches gameCount. I have tried a few different things that have all failed. Here is a little snippet of the code.

int gameCount = [count intValue];
    int gameRows = 0;
    while (gameCount > gameRows) {
        gameRows++;
         NSString *thisUser = (NSString *) [dictionaryReturn objectForKey:@"away%i", gameRows];

This obviously does not work but I figured I was at least heading in the right direction.

1 Answer 1

1

I don't understand the purpose of the rest of the code, but at least this part should be writen this way:

...[dictionaryReturn objectForKey:[NSString stringWithFormat:@"away%i", gameRows]]

Good luck!

Sign up to request clarification or add additional context in comments.

4 Comments

Yea I wasn't very clear but your answer was perfect. Thanks!
Actually the only other thing is how can I make the pointer *thisUser increment like "away" does?
basically i just want to concatenate *thisUser and gameRows if possible
ond simple way to concat strings is [NSString stringWithFormat:@"%@ %@ %i", string1, string2, i]

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.