I’m trying to make use of a dictionary plist as shown below:
I read it into a temp dictionary just fine.
What I’d like to know is if there is an easy way to get at the string children (which are actually a single element in an array, as you can see).
I initially tried objectAtIndex but that was, of course, returning an array, not the string value. I next tried using an NSEnumerator (an objectEnumerator) and then use objectAtIndex:0 to get me the string which does work.
But I’m really hoping there is an easier way to do that.
Edit: clarifying what I’m trying to do.
I want to use the key values (e.g. “All Items”) to populate a tableview cell.text and then use the string values (e.g. “find.png”) in order to help populate cell.image via UIImage imageNamed:. I would prefer NOT to use hard-coded values (such as objectForKey:@”All Items”) so that I can change the data in the plist without also making code changes.
You need to call
objectForKey:on the dictionary to get one of the arrays, and then callobjectAtIndex:0(or justlastObject) on the array to get the string. You can combine these two method calls into one line of code, for example: