2016-04-10 139 views
-3
PFQuery *query = [PFQuery queryWithClassName:@"Category"]; 
    // Retrieve the object by id 
    [query findObjectsInBackgroundWithBlock:^(NSArray * _Nullable objects, NSError * _Nullable error) { 
     // Now let's update it with some new data. In this case, only cheatMode and score 
     // will get sent to the cloud. playerName hasn't changed. 
//  NSLog(@"%@",[objects objectAtIndex:1]); 
//  NSLog(@"%@",[objects valueForKey:@"mensClothingType"]); 
     NSArray * result = [[objects valueForKey:@"mensClothingType"] componentsJoinedByString:@""]; 
     NSLog(@"%@",result); 
    }]; 
} 

我如何從對象中獲取所有'mensClo​​thingType'並將其放入一個數組中?目前,如果我讀出數組「對象」我怎樣才能把這個數組放入一個數組?

我得到這個:

(
     (
     Shirts 
    ), 
     (
     Jeans 
    ) 
) 
+0

更新您的一些相關的代碼的問題,表明你已經嘗試過的東西。解釋你在嘗試中遇到了什麼問題。 – rmaddy

+0

看一下'NSArray'方法'arrayByAddingObjectsFromArray'。如果你發佈你的代碼和你已經嘗試過,我們可以告訴你如何使它工作。 –

+0

我更新了@rmaddy – farhan

回答

0
NSMutableArray* resultArray = [NSMutableArray new]; 
for(NSArray* innerArray in outerArray) 
{ 
    for(id object in innerArray) 
    { 
     [resultArray addObject:object]; 
    } 
}  
相關問題