hi all!
i have a NSDictionary with NSString and NSArray
i have to save in a variable only the NSArray without know the key.
Is Possibile?
Thx all
And sorry for my bad english
hi all!
i have a NSDictionary with NSString and NSArray
i have to save in a variable only the NSArray without know the key.
Is Possibile?
Thx all
And sorry for my bad english
If I'm understanding you correctly, you have a dictionary that contains both an NSString and an NSArray, and you want to extract just the NSArray, without knowing what the key is.
One way to do that is to look through the dictionary with fast enumeration:
NSString *key;
for(key in someDictionary){
id someObject = [someDictionary objectForKey: key];
}
and then look at the objects to see which one is an NSArray:
if ([someObject isKindOfClass:[NSArray class]]) {
// do something with the array
}
(obligatory warning: explicitly checking an object's class is often a sign of a flawed design. In most cases, you should be checking for behavior (-respondsToSelector
), not class identity)