I have array like this:
{
toNumber = +79995840405;
type = 9;
}
{
toNumber = +79995840405;
type = 65;
}
{
toNumber = +79995840405;
type =
You have provided little detail, which makes it hard for people to help you; and haven't shown what you have tried yourself and explained where you got stuck, which is the SO approach - people here will help you, not do the work for you.
The above is why you are getting close votes.
That said let's see if we can point you in the right direction, but understand this is based on guesswork about what you have and your problem.
So it sounds like you have an array (NSArray
) of dictionaries (NSDictionary
) and wish to produce a dictionary of arrays. A straightforward iteration can be used for that:
NSMutableDictionary
)foreach
)Using the type
value of your element as the key value of your result dictionary:
3.1. If there is no entry in your result dictionary for the key create a new array (NSMutableArray
), add the element's toNumber
value to it, and add the array to your result dictionary.
3.2 Otherwise simply add to toNumber
value to the existing array at the key entry of your result dictionary.
That's it, each bullet is a line or two of code.
If you get stuck as a new question, providing details, showing your code, and explaining what you problem is. Someone will undoubtedly help you from there.
HTH