hi i am creating a tabbar app where in second tab i am creating a table and trying to display the info using plist but my table view is not displaying anything and my plist is in the format given below like that i have 300 names how should i can retrieve plist and display it in table view plz replay me thanks in advance.
plist format :
root dictionary
book dictionary
hhh dictionary
name hhh
meaning bye
go dictionary
name go
meaning going
like dis i have defined plist and i want to retrieve and diplay in tableview
plist format :
root dictionary
book dictionary
hhh dictionary
name hhh
meaning bye
go dictionary
name go
meaning going
like dis i have defined plist and i want to retrieve and diplay in tableview
Code:
- (void)viewDidLoad
{
NSDictionary *contactList = [propertyList readFromArchive:@"Book"];
[self setBook:[contactList objectForKey:@"book"]];
[self setTitle:@"Contacts"];
[self myTable];
NSLog(@"gggggg");
}
- (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 [dag count];
return [[[self book] allKeys] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *keys = [[[self book] allKeys]sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)]; NSString *key = [keys objectAtIndex:[indexPath row]];
NSDictionary *contact = [[self book] objectForKey:key];
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.textlabel.text =[contact objectForKey:@"name"];
return cell;
}
Last edited by a moderator: