user1828081
user1828081

Reputation: 81

read data from Plist based on value of a Variable

I have a plist with multiple parent categories that are places and I want to allow the user to select the place and the only data from the child class of that plist are returned based on the value of a variable. What is passed into the variable will be the same as the name of the parent category. How can I retrieve different information from the plist based on the value of a variable?

Upvotes: 0

Views: 72

Answers (1)

JMarsh
JMarsh

Reputation: 954

Just create an NSDictionary that holds the plist's data, and then create an array that holds the data of the variable.

NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] 
        pathForResource:@"yourPlist" ofType:@"plist"]];
NSArray *array = [dictionary objectForKey:variable];

Upvotes: 1

Related Questions