MeisterPlans
MeisterPlans

Reputation: 129

How do I pull only keys of certain types from a plist into an array?

I have a plist with multiple keys in it. I am currently able to load all of the keys into an array, but I would like to only load the keys of type string into the array. Is there a way to code it so I only get the names of the keys from the plist that are of type string?

Thanks!!

Upvotes: 0

Views: 135

Answers (1)

Warren Burton
Warren Burton

Reputation: 17382

You can iterate through the contents of the plist and use [obj isKindOfClass:[NSString class]] to pick only the strings.

for(id key in [mydictionary allKeys])
{
id obj = [mydictionary objectForKey:key];
   if([obj isKindOfClass:[NSString class]])
   {
      [myarray addObject:key];
   }
}

Upvotes: 1

Related Questions