Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode/Parse-PFQuery NSMutableArray问题_Xcode_Arrays_Parsing_Nsmutablearray - Fatal编程技术网

Xcode/Parse-PFQuery NSMutableArray问题

Xcode/Parse-PFQuery NSMutableArray问题,xcode,arrays,parsing,nsmutablearray,Xcode,Arrays,Parsing,Nsmutablearray,[这可能是一个noob问题,但我花了很多时间来解决这个问题。] 基本上,我使用www.parse.com服务将数据存储在云中。我正在检索一个名为objects的NSArray,它在控制台中的结果是: 2013-03-25 19:59:06.118 app[18960:c07] ( "<users:u8WRDUlfVg:(null)> {\n pairs = (\n 14120151,\n 14749606,\n 17230018

[这可能是一个noob问题,但我花了很多时间来解决这个问题。]

基本上,我使用www.parse.com服务将数据存储在云中。我正在检索一个名为objects的NSArray,它在控制台中的结果是:

2013-03-25 19:59:06.118 app[18960:c07] (
"<users:u8WRDUlfVg:(null)> {\n    pairs =     (\n        14120151,\n        14749606,\n        17230018\n    );\n    username = GeoffroyMorel;\n}"
)
console中的结果非常好,只是增加了一对括号(这可能是以下问题的原因):

现在的问题是,当我试图添加一个对象,并在控制台中显示结果时,它会用括号括起来,如下所示:

2013-03-25 20:02:45.887 app[18960:c07] (
    (
            (
        14120151,
        14749606,
        17230018
    ),
    15749606
)
)
2013-03-25 20:02:45.887 app[18960:c07] (
    14120151,
    14749606,
    17230018,
    15749606
)
我想要这样:

2013-03-25 20:02:45.887 app[18960:c07] (
    (
            (
        14120151,
        14749606,
        17230018
    ),
    15749606
)
)
2013-03-25 20:02:45.887 app[18960:c07] (
    14120151,
    14749606,
    17230018,
    15749606
)

谢谢你的帮助,我确信我错过了一行可以正确订购NSMutableArray的内容。

好的,我刚刚找到了答案,我没有注意到从查询中收到的“对象”是NSArray!您所需要的就是:

PFQuery *query = [PFQuery queryWithClassName:@"Users"];
[query whereKey:@"username" equalTo:userAccount.username];

[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
    NSLog(@"%@", objects);

    NSArray *array = [objects objectAtIndex:0];//Selects the first "object" from all the "objects"
    array = [array valueForKey:@"pairs"];//Makes a NSArray from the "pairs" values
    pairs = [array mutableCopy];//Converts the array to a NSMutableArray

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