如何从解析数据库xcode / ios获取第二行值?

时间:2015-06-21 21:29:55

标签: ios objective-c swift parse-platform

所以我来自android,刚刚开始使用obj-c / swift / ios开发。我正在使用解析并运行查询,我正在尝试做的是运行查询并访问第二行数据并从第二行获取值。任何帮助将不胜感激,谢谢!

 PFQuery *query1 = [PFQuery queryWithClassName:@"GameResults"];
[query1 whereKey:@"gameName" equalTo:@"GameOne"];
[query1 orderByDescending:@"gameFullDate"];
[query1 findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
    // results will contain users with a hometown team with a winning record

    PFObject object = [booksArray objectAtIndex:1];


    _nextGame.text =[object objectForKey:@"nextGame"];

}];

1 个答案:

答案 0 :(得分:1)

您可以发布您的查询代码吗?

如果使用find / fetch方法执行查询,则返回结果是PFObject数组。只需迭代此数组即可访问第二个值

[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {
     if (!error) {
         // The find succeeded.

         // Do something with the found objects
         for (PFObject *object in results) {                
             NSLog(@"Object Name: %@", object.objectId);
             // Here you can cast you object in GameResult for example.         
             object.score etc
         }


    } else {
         // Log details of the failure
         NSLog(@"Error: %@ %@", error, [error userInfo]);
     }
 }];