Ios 如何从parse.com查询数据
我正在尝试从parse.com获取数据,并验证是否存在记录,如果存在,则执行segue 这是我的测试代码: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
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){
?