ios - Remove (not exact) duplicates of NSDictionaries from array -


i have nsmutablearray of many nsdictionaries contain keys "title". in cases there duplicates of dictionaries same "title" differences in other keys. how can remove dictionaries have same "title" key , leave 1 in array?

thanks

sort array using nssortdescriptor on key path 'title'. next, loop on array , build new array:

nsstring *lasttitle = nil; nsmutablearray *result = [nsmutablearray array];  (nsdictionary *d in array) {     nsstring *testtitle = [d objectforkey:@"title"];     if (![testtitle isequaltostring:lasttitle]) {         [result addobject:d];         lasttitle = testtitle;     } } 

now result contains filtered list.

it's important sort array first algorithm work.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -