How do I populate a textfield with data from a plist

marthakarachi

New Member
Im trying to figure out how to populate the textfield in the DVC with data from the plist. I have gotten the data to populate into the tableview cells with know issue. I have not posted the . M for the DVC because simply put. I don't know what to add there ...xml / plist\[code\] <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><array> <dict> <key>cellName</key> <string>Sharon Lodge No. 327</string> <key>cellSubtitle</key> <string>McLean, VA</string> <key>address</key> <string>999 Balls Hill Road</string> <key>webSite</key> <string>www.website.com</string> <key>statedCom</key> <string>Hold meetins on...</string> </dict> <dict> <key>cellName</key> <string>Sharon Lodge No. 327</string> <key>cellSubtitle</key> <string>McLean, VA</string> <key>address</key> <string>999 Balls Hill Road</string> <key>webSite</key> <string>www.website.com</string> <key>statedCom</key> <string>Hold meetins on...</string> </dict>\[/code\].h for DVC\[code\]#import <UIKit/UIKit.h>@interface DetailViewController : UIViewController@property (strong, nonatomic) IBOutlet UILabel *address;@property (strong, nonatomic) IBOutlet UILabel *webSite;@property (strong, nonatomic) IBOutlet UILabel *statedCom;@end\[/code\].h for talbleview\[code\]#import <UIKit/UIKit.h>@interface plistTableViewController : UITableViewController{ NSArray *tabledata;}@end\[/code\].M for Tableview\[code\]#import "plistTableViewController.h"#import "DetailViewController.h"@interface plistTableViewController ()@end@implementation plistTableViewController- (id)initWithStyle:(UITableViewStyle)style{ self = [super initWithStyle:style]; if (self) { // Custom initialization } return self;}- (void)viewDidLoad{ NSString *mylist = [[NSBundle mainBundle] pathForResource:@"lodges" ofType:@"plist"]; tabledata = http://stackoverflow.com/questions/14086839/[[NSArray alloc]initWithContentsOfFile:mylist]; NSLog(@"%@", tabledata); [super viewDidLoad]; }- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ // Return the number of sections. return 1;}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ // Return the number of rows in the section. return [tabledata count];}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; if( cell == nil ) { NSLog(@"Cell Creation"); cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"]; } //Set Data For each Cell cell.textLabel.text = [[tabledata objectAtIndex:indexPath.row]objectForKey:@"cellName"]; cell.detailTextLabel.text = [[tabledata objectAtIndex:indexPath.row]objectForKey:@"cellSubtitle"]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell;}-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{}\[/code\]
 
Back
Top