I’m trying to pull some data from plist file and display it in a text field (from a UIButton click). the code below pulls the address of the plist and not the data. any help is greatly appreciated. thanks
-(IBAction) buttonPress {
NSString *path = [[NSBundle mainBundle] pathForResource:@"messages" ofType:@"plist"];
NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:path];
[myMessage setText:path];
}
yeah, you’re printing out the path, not any item in the array. Change
to
Also you can change your plist to contain a dict and not an array so you could call specific text –
In response to your question about arc4random.
Create an enum so that you can create a switch statement –
then create a random integer and mod it by x so that you get a number btw 0 and x-1. (In this case, since we have 3 things inside the enum, x = 3)
then use that random int in a switch statement
hope this works. I havent tried this before…