我正在尝试从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);
}
}];