2013-12-12 19 views
1

我在我的iPhone應用程序中使用解析webservice。 我可以保存和檢索我的帳戶中的數據。從解析webservice獲取保存的數據?

我下面取保存的數據 -

-(void)Fetch{ 

     PFQuery *query = [PFQuery queryWithClassName:@"Gossips"]; 
     [query orderByDescending:@"createdAt"]; 
     [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { 
    if (!error) { 
     NSArray* wallObjectsArray = [[NSArray alloc] initWithArray:objects]; 
     NSLog(@"wallObjectsArray:--------- %@", wallObjectsArray); 

    } else { 
     NSString *errorString = [[error userInfo] objectForKey:@"error"]; 
     NSLog(@"Error: %@", errorString); 
     } 
    }]; 
    } 

和出放 -

wallObjectsArray:--------- "<MyApp:dPotrdMmZy> {\n category = politics;\n content = \"Madiba died..!!\";\n user = john;\n}", 

我怎樣才能檢索此數組不同的密鑰每個對象。 我想了解一下這是什麼內容,誰是用戶?

回答

0

嘗試

for (PFObject *innerObject in objects) 
{ 
    NSLog(@"WallObjects:------ %@", innerObject); 

} 
0

我只是添加了「for」循環,讓你有一些樣本「用戶名」想要的信息和「分數」字段,需要改變到什麼在你parse.com類。

希望它可以幫助

-(void)Fetch{ 
PFQuery *query = [PFQuery queryWithClassName:@"Gossips"]; 
    [query orderByDescending:@"createdAt"]; 
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) { 
     if (!error) { 
      // NSArray* wallObjectsArray = [[NSArray alloc] initWithArray:objects]; 
     // NSLog(@"wallObjectsArray:--------- %@", wallObjectsArray); 

      for (PFObject *info in objects) { 

       NSLog(@"Id: %@", info.objectId); 
       NSLog(@"User: Name %@", [info objectForKey:@"UserName"]); 
       NSLog(@"Score: %@", [info objectForKey:@"Score"]); 
      } 
     } else { 
      NSString *errorString = [[error userInfo] objectForKey:@"error"]; 
      NSLog(@"Error: %@", errorString); 
     } 
    }]; 

}