Thursday 15 August 2013

iphone - How to extract specific data has equal value for some key from NSDictionary into a combined NSArray -


Now I have a dictionary like this, it's just an example, I am from Z:

  ({id = 13; name = "roll"; firstLetter = R;}, {id = 14; name = "scroll"; firstLetter = S;}, {id = 16; name = "rock"; First liter = R;}, {id = 17; name = "start"; first liter = s;})   

I want to extract that is the first letter and these are A NSERE object. Expected results like this:

R array:

  ({id = 13; name = "roll"; first = r;}, {id = 16; name = "Rock"; first letter = r;})   

and S array:

  ({id = 14; name = "scroll"; First letter = s;}, {id = 17; name = "start"; first liter = s;})   

how to do this?

I believe that a better suggestion will be made

but it Customize as @ "R"}, @ "Roll", @ "First Time": @ 13, @ "Name": @ "R"}

  NSArray * array = @ [ @ @ "@": @ 14, @ "name": @ "@" @ @, @ "@" @ @ @ "First"), @ "First Letter", @ "First Litter": @ "R"}, @ {@ "ID": @ 16, @ "Name": @ "Start", @ "First"): @ "S "}]; NSMutableDictionary * dictionary = [NSMutableDictionary dictionary]; [Calculate the array using the commands: lock: ^ (NSDRIVATION * Dict, NSUnitezer IDX, BOL * stop) {nssting * key = dec [@ "first letter"]; NSMutableArray * tempArray = Dictionary [key]; If (TempArray) {tempArray = [NSMutableArray array]; } [TempArray addObject: dict]; Dictionary [key] = tempArray; }]; NSLog (@ "% @", Dictionary);    

No comments:

Post a Comment