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