Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/104.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
Ios 如何从parse.com查询数据_Ios_Objective C_Parse Platform - Fatal编程技术网

Ios 如何从parse.com查询数据

Ios 如何从parse.com查询数据,ios,objective-c,parse-platform,Ios,Objective C,Parse Platform,我正在尝试从parse.com获取数据,并验证是否存在记录,如果存在,则执行segue 这是我的测试代码: PFQuery *query = [PFQuery queryWithClassName:@"codes"]; [query whereKey:@"code" equalTo:_code.text]; [query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) { // comments

我正在尝试从parse.com获取数据,并验证是否存在记录,如果存在,则执行segue

这是我的测试代码:

PFQuery *query = [PFQuery queryWithClassName:@"codes"];
[query whereKey:@"code" equalTo:_code.text];

[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
    // comments now contains the comments for myPost
    if (comments) {
        NSLog(@"Success!");
    }else{
        NSLog(@"Fail!");
    }
}];
解决方案:

NSString *code1 = _code.text;
NSNumber *code2 = [NSNumber numberWithInt:[code1 integerValue]];
// Assume PFObject *myPost was previously created.
PFQuery *query = [PFQuery queryWithClassName:@"present_codes"];
[query whereKey:@"code" equalTo:@([code2 integerValue])];

[query findObjectsInBackgroundWithBlock:^(NSArray *comments, NSError *error) {
    // comments now contains the comments for myPost
    if (comments.count > 0) {
        NSLog(@"Success!: %@", comments);
    }else{
        NSLog(@"Fail!: %@", comments);
    }
}];

你有问题吗?是的,日志中的值总是成功的,但是类中没有这样的值,我不知道如何正确验证。-谢谢你的回复。那么
注释
数组包含什么呢?它是空的,但是日志是成功的。那么你想
如果(comments.count>0){