Reputation: 6857
I have a Objective C class that has the following attributes
@property(nonatomic, strong) NSString *name;
@property(nonatomic, strong) NSMutableArray *companies;
@property(nonatomic, strong) NSMutableArray *users;
@property(nonatomic, strong) NSMutableArray *tags;
These arrays are collections of other objects (instances of Company,User and Tag class). I need to create a requestDescriptorWithMapping for the POST request which will put all the members of the arrays into a single one named params with the following structure:
{ name: "Test",
params: [
{param:'company', values:['CompanyName1','CompanyName2'..],
{param:'users', values:['UserName1','UserName2'..]
]
}
What would be the best way to go here? I'm testing RKBlockValueTransformer but so far no success. I can create this array manually by creating three NSMutableDictionaries but wanted to check is there a better way to this.
Upvotes: 0
Views: 84
Reputation: 55594
You could do this:
[@{ @"name": self.name,
@"params": @[
@{@"param":@"company", values:[self.companies valueForKey:@"name"]}
@{@"param":@"users", values:[self.users valueForKey:@"name"]}
]
} mutableCopy]
Assuming you Company and User classes have a name property. And if you're not using ARC you'll need to autorelease the result of mutableCopy
Upvotes: 1