Hi all,
I want to display the datas present in the plist file. I have written the code, but my code is not fetching the data from plist file. Here is my - code
If anyone knows where i did the mistake, kindly suggest me.
Regards
sakthi
I want to display the datas present in the plist file. I have written the code, but my code is not fetching the data from plist file. Here is my - code
Code:
(void)viewDidLoad {
NSString *myFile = [[NSBundle mainBundle]pathForResource:@"breakdown" ofType:@"plist"];
numbers = [[NSArray alloc]initWithContentsOfFile:myFile];
NSLog(@"%@",numbers);
[SIZE="4"]//numbers is an array and breakdown is my plist file
// My console file generates null value, but my plist file contains values[/SIZE]
[super viewDidLoad];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 6;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
if(section == 0) return 0;
if(section == 1) return 2;
if(section == 2) return 2;
if(section == 3) return 2;
if(section == 4) return 2;
if(section == 5) return 3;
return numbers.count;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
int theRow = indexPath.row;
if(indexPath.section == 0)
if(indexPath.section == 1)theRow += 2;
if(indexPath.section == 2) theRow += 4;
if(indexPath.section == 3) theRow += 6;
if(indexPath.section == 4) theRow += 8;
if(indexPath.section == 5) theRow += 11;
cell.textLabel.text = [numbers objectAtIndex:theRow];
// Configure the cell...
return cell;
}
Regards
sakthi
Last edited by a moderator: