To compare the two array I used NSMutableSet and then intersect the two sets to get the common result in an array. NSMutableSet *set1 = [NSMutableSet setWithArray:array];
[set1 intersectSet:[NSSet setWithObject:[NSNumber numberWithInt:70]]];
NSArray *intersectArray = [[NSArray alloc]init];
intersectArray =[set1 allObjects];
NSLog(@"the testing array is %@",[intersectArray objectAtIndex:0])];
It gives me perfect answer but it get crashed when set1 does not have common element as that of set2. intersectArray is empty . How to get nil value for intersectArray.
countproperty to check if array has any items.[[NSArray alloc]init];and then throw it away on the next line by setting a different value - very wasteful...