I've created a plist and filled it with data by modifying the myPlist.plist file directly. How can i read values from it and display them on the output. I'm working with grouped tables and i want to fill the data of the cells from the plist i created earlier.开发者_JAVA百科 Any Suggestions?
If you are storing the content as an NSDictionary
, then this is how you have to access it from the plist:
NSString *myFile = [[NSBundle mainBundle] pathForResource:@"myList" ofType:@"plist"];
NSMutableDictionary* myDict = [[NSMutableDictionary alloc]initWithContentsOfFile:myFile];
NSLog(@"%@", myDict);
Obtain the data in an array if you have stored the data as NSArray
.
To display it in the tableview use the following code:
cell.textLabel.text = [myArray objectAtIndex:indexPath.row];
Write the above code inside -tableView:cellForRowAtIndexPath:
method.
精彩评论