I have NSDictionaries in NSArray just like below.
array(dictionary(“user”:1, “p1”:1), dictionary(“user”:2, “p1”:3),
dictionary(“user”:1, “p1”:5), dictionary(“user”:2, “p1”:7))
And I want to turn this array into dictionary like below.
NSArray *u1 = [NSArray arrayWithObjects:@"1", @"5", nil];
NSArray *u2 = [NSArray arrayWithObjects:@"3", @"7", nil];
keys = [NSArray arrayWithObjects:@"u1", @"u2", nil];
points = [NSDictionary dictionaryWithObjectsAndKeys:u1, @"u1", u2, @"u2", nil];
How can I do that? I am lost, can you guys please help me?
Another possible solution (works with an arbitrary number of users):
Output:
And the keys can be obtained by