I am looking to check if NSMutableArray contains NSMutableDictionary, I know we can check for NSDictionary with
[array indexOfObjectIdenticalTo:dict];
But cannot work out how to check for NSMutableDictionary. Any hint would be great.
Thanks.
You can check the objects in array with type of class.
for (id object in mutableArray) {
if ([object isKindOfClass:[NSMutableDictionary class]]) {
// Mutable dictionary object
NSInteger iIndex = [mutableArray indexOfObject:object];
}
else if ([object isKindOfClass:[NSDictionary class]]) {
// Non-mutable dictionary object
NSInteger iIndex = [mutableArray indexOfObject:object];
}
}
isKindOfClass can also be useful here.
you can check a specific index this way
if ([[myArray objectAtIndex:myIndex] isKindOfClass:[NSDictionary class]])
whereas this NSDictionary can be replaced by any Data Type that you want to compare with for example NSArray, NSString and others. I hope it helps you in distinguishing the types of data.