objective c - Check common values between two NSArray of NSDictionaries -
i have 2 nsarray, noticloud , notiloc, both nsdictonary of same structure. need know how check how many nsdictionary in both nsarray, instance using key @"id".
many thanks.
// create arrays of ids nsarray *noticloudids = [noticloud valueforkey:@"id"]; nsarray *notilocids = [notiloc valueforkey:@"id"]; // turn arrays sets , intersect 2 sets nsmutableset *noticloudidsset = [nsmutableset setwitharray:noticloudids]; nsmutableset *notilocidsset = [nsmutableset setwitharray:notilocids]; [noticloudidsset intersectset:notilocidsset]; // ids in noticloudidsset have been present in both arrays nslog(@"duplicate ids: %@", noticloudidsset);
Comments
Post a Comment