Been slowly picking up the basics in IOS Programming, but seemed to have hit a small hurdle
I have a table that gets populated from a plist located on a webserver
<?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">
<dict>
<key>Item 0</key>
<dict>
<key>eventDate</key>
<string>27-06-2012</string>
<key>eventTitle</key>
<string>Clinic</string>
</dict>
<key>Item 1</key>
<dict>
<key>eventDate</key>
<string>28-06-2012</string>
<key>eventTitle</key>
<string>Clinic</string>
</dict>
<key>Item 2</key>
<dict>
<key>eventDate</key>
<string>28-06-2012</string>
<key>eventTitle</key>
<string>Office Closed</string>
</dict>
<key>Item 3</key>
<dict>
<key>eventDate</key>
<string>29-06-2012</string>
<key>eventTitle</key>
<string>Tour</string>
</dict>
</dict>
</plist>
Now after doing a punt load of reading I have managed to hack together this code to populate a Table.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell * cell =[tableView dequeueReusableCellWithIdentifier:@"cell"];
if (nil == cell)
{
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:@"cell"];
}
NSString *currentEventName;
currentEventName = [eventKey_web objectAtIndex:indexPath.row];
[[cell textLabel] setText:currentEventName];
return cell;
}
...
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL * myURL1;
myURL1 = [NSURL URLWithString:@"http://www.mywebsite.com/events.plist"];
event_web = [[NSDictionary alloc] initWithContentsOfURL:myURL1];
eventKey_web = [event_web allKeys];
}
Now my table is populating but only with Item 0, Item 1, Item 2
My goal is to populate the table with eventTitle as the description.
Sorry for the possibly dumb question but still trying to get my head around Objective C
You have to get the NSDictionary by your key in the function, and retrieve the corresponding data from your dictionary.