Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7672431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:17:02+00:00 2026-05-31T16:17:02+00:00

Really struggling to figure this out. Just trying to take in data from php

  • 0

Really struggling to figure this out. Just trying to take in data from php

curRow = [[NSMutableArray alloc]init];
    [curRow addObject:[JSON valueForKeyPath:@"question"]];
    [curRow addObject:[JSON valueForKeyPath:@"answers"]];
    [curRow addObject:[JSON valueForKeyPath:@"correct_answer"]];
    [gameQuestions addObject:curRow];

in another method, I’m doing this

int i = arc4random() % [gameQuestions count];
CCLOG(@"Random: %i", i);

currentQuestion = [[gameQuestions objectAtIndex:i]objectAtIndex:0];
currentAnswer = [[gameQuestions objectAtIndex:i]objectAtIndex:1];
currentCorrectAnswer = [[gameQuestions objectAtIndex:i]objectAtIndex:2];
CCLOG(@"question: %@", currentQuestion);
CCLOG(@"answer: %@", currentAnswer);

But when I look in the debug log, my question and answer are the same object?

2012-03-21 17:08:06.659 dunce[6849:707] Random: 0
2012-03-21 17:08:06.662 dunce[6849:707] question: (
    "Who was the 42nd president?",
    "What was the date that Microsoft released Windows 95?"
)
2012-03-21 17:08:06.666 dunce[6849:707] answer: (
    "Bill Clinton; Theodore Rosevelt; Barack Obama; Ronald Regan; ",
    "June 25th, 1994;September 3rd, 1992; August 24th, 1995; August 3rd, 1996"
)

i must be missing something

in php its just a simple while loop

while($row = mysql_fetch_array($result))
{
    $resultArr[$co]['id'] = $row['id'];
    $resultArr[$co]['question'] = $row['question'];
    $resultArr[$co]['answers'] = $row['answers'];
    $resultArr[$co]['correct_answer'] = $row['correct_answer'];
    $co++;
}

echo json_encode($resultArr);

any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:17:03+00:00Added an answer on May 31, 2026 at 4:17 pm

    i got it.

        AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
        for(id entry in JSON)
        {
            NSMutableArray *curRow = [[NSMutableArray alloc]init];
            [curRow addObject:[entry valueForKeyPath:@"question"]];
            [curRow addObject:[entry valueForKeyPath:@"answers"]];
            [curRow addObject:[entry valueForKeyPath:@"correct_answer"]];
            [gameQuestions addObject:curRow];
            [curRow release];
            curRow = nil;            
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm really struggling to figure out how to iterate through some data and then
Hey everyone. I'm really struggling to figure out the logic with this one and
Hey, I'm really struggling with this one. I'am trying to port a small piece
I'm struggling with this problem for a day now, and I just can't figure
Hi iv been struggling with this error for some time and really cant figure
I'm struggling to figure this one out, sessions work when i run my application
Really struggling to figure out extending the immutable Set with a class that will
OK i am really struggling with this! I know had to add an image
For some reason I'm really struggling with this. I'm new to wpf and I
I am trying to read the following xml stream but am really struggling. <channelSnapshot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.