2015-03-02 56 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]); 
     } 
    }]; 
相關問題