Display Text From Plist Dictionary by Pressing Button
I have a "noobie" question (I'm new at iPhone) Anyway, I've populated a Plist called temp.plist with several items in a dictionary. The first item is called "+0开发者_StackOverflow+1" the second is called "+0+2" and so on.
They each have text to be displayed when called when a button is pushed on the iPhone. When I Push Button "1", I want the Text from "+0+1" to display to the screen and so on.
I've seen some examples using NSArray, but since I have these in Dictionary format I'm not sure if that's the proper way to proceed.
Can you point me to some examples of displaying text from a Plist Dictionary when a condition = "yes"?
You can retrieve your dictionary from your plist and store in in a dictionary variable like:
NSString * plistPath = [[NSBundle mainBundle] pathForResource:@"temp" ofType:@"plist"];
NSDictionary *myDictionary = [[NSDictionary dictionaryWithContentsOfFile:plistPath];
Then, to retrieve items from the dictionary, call objectForKey on it
NSString *myText = [myDictionary objectForKey:@"+0+1"];
精彩评论