我是Parse.com的新手我试着用相同的键从Parse表中获取数据但是值不同如
-(void)getdata
{
NSMutableArray *allObjects = [NSMutableArray array];
NSUInteger limit = 1000;
__block NSUInteger skip = 0;
PFQuery *query = [PFQuery queryWithClassName:@"MapInfo"];
[query whereKey:@"Type" containedIn:@[@"Temporary", @"Business"]];
[query setLimit: limit];
[query setSkip: skip];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
[allObjects addObjectsFromArray:objects];
if (objects.count == limit) {
skip += limit;
[query setSkip: skip];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
[allObjects addObjectsFromArray:objects];
self.qpinname=[allObjects valueForKey:@"GPIN"];
NSLog(@"Qpin Array %lu",(unsigned long)[self.qpinname count]);
self.locationArray=[allObjects valueForKey:@"Location"];
self.latitude=[self.locationArray valueForKey:@"lat"];
self.longitude=[self.locationArray valueForKey:@"lng"];
self.address=[allObjects valueForKey:@"Address"];
self.usernameArray=[allObjects valueForKey:@"AddedBy"];
[self getdata2];
hudView.hidden=TRUE;
}];
}
}
else
{
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}
-(void)getdata2
{
NSMutableArray *allObjects = [NSMutableArray array];
NSUInteger limit = 1000;
__block NSUInteger skip = 0;
PFQuery *query = [PFQuery queryWithClassName:@"MapInfo"];
[query whereKey:@"Type" equalTo:@"Personal"];
[query setLimit: limit];
[query setSkip: skip];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
[allObjects addObjectsFromArray:objects];
if (objects.count == limit) {
skip += limit;
[query setSkip: skip];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
[allObjects addObjectsFromArray:objects];
self.lqpinname=[allObjects valueForKey:@"GPIN"];
NSLog(@"Qpin Array %lu",(unsigned long)[self.lqpinname count]);
self.llocationArray=[allObjects valueForKey:@"Location"];
self.llatitude=[self.llocationArray valueForKey:@"lat"];
self.llongitude=[self.llocationArray valueForKey:@"lng"];
self.laddress=[allObjects valueForKey:@"Address"];
self.usernameArray=[allObjects valueForKey:@"AddedBy"];
}];
}
}
else
{
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
}
这里我想获取相同密钥的数据,但是在不同的数组中,但它不适合我,请给我解决方案。
感谢。
答案 0 :(得分:0)
我不确定这是否是您想要做的事情,但是:
PFQuery *query = [PFQuery queryWithClassName:@"MapInfo"];
[query whereKey:@"Type" containedIn:@[@"Temporary", @"Business", @"Personal"]];
[query findObjectsInBackgroundWithBlock:^(NSArray *result, NSError *error) {
if (!error && result.count)
{
for (PFObject *parseResponse in result)
{
if ([[parseResponse objectForKey:@"Type"] isEqual:@"Personal"])
{
//the logic for data with Type = Personal
}
else
{
//the logic for the data with other Types
}
}
}
else
{
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];