开发者

Plist - iPhone Development

开发者 https://www.devze.com 2023-03-22 05:43 出处:网络
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'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.

0

精彩评论

暂无评论...
验证码 换一张
取 消