2015-03-02 55 views
-2

我是新手到Parse.com我尝试用相同的密钥,但值来从解析表中的数据是一样的如何从不同数组中的相同键获取数据解析iOS?

-(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

究竟是关键,数组你究竟是什么?你有一个列数组的设置,你不想添加另一个,因为它是相同的值(键) – soulshined 2015-03-02 17:36:05

回答

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]); 
     } 
    }]; 
相关问题