小编lsi*_*uex的帖子

afnetworking json成多维数组

真的很难搞清楚这一点.只是试图从PHP中获取数据

curRow = [[NSMutableArray alloc]init];
    [curRow addObject:[JSON valueForKeyPath:@"question"]];
    [curRow addObject:[JSON valueForKeyPath:@"answers"]];
    [curRow addObject:[JSON valueForKeyPath:@"correct_answer"]];
    [gameQuestions addObject:curRow];
Run Code Online (Sandbox Code Playgroud)

在另一种方法中,我这样做

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);
Run Code Online (Sandbox Code Playgroud)

但是当我查看调试日志时,我的问题和答案是同一个对象?

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; …
Run Code Online (Sandbox Code Playgroud)

objective-c ios afnetworking

3
推荐指数
1
解决办法
2195
查看次数

标签 统计

afnetworking ×1

ios ×1

objective-c ×1