sathya
sathya

Reputation: 384

Why table view not showing any data in iphone

When parsing a local XML file i can see the data in console using NSLog. While in the simulator am getting only the plain table view without any data parsed from xml. Am not understanding where am missing it.

StoryBoard

- (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];      

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;  
    }  

    theLists = [app.listArray objectAtIndex:indexPath.row];
    cell.textLabel.text = theLists.title;  
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}

Upvotes: 1

Views: 3170

Answers (5)

Munib
Munib

Reputation: 967

Figured I should add this, if you are having trouble with data not showing up or loading.

Make sure your tableview delegate and data source are set to self.

So in the viewcontroller's viewDidLoad() function, make sure you add

tableView.delegate = self
tableView.dataSource = self

Upvotes: 0

sathya
sathya

Reputation: 384

I got the answer finally where i didn't properly connected the tableview controller class with corresponding controller. I followed the link Trouble making connections with story board

And finally it showed the data in the table view. Hope this answer might help others. Thanks for all the people who gave their suggestions in this post.

Upvotes: 0

Ayman Melhem
Ayman Melhem

Reputation: 493

I think there are two expected reasons for that:

1- May be the number of sections and number of row are not set with the correct value.

2- may be you need to reload the table view data.

Please check these two methods:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

return 5; // or any number you want

}

Upvotes: 0

EXC_BAD_ACCESS
EXC_BAD_ACCESS

Reputation: 2707

It seems you are reloading in the DidLoad.But After parsing and getting the data from xml, You have to reload that data with TableView.

[yourtableView reloadData];

Before doing thing, be sure that you have set Delegate and DataSource.

Upvotes: 0

Bhrigesh
Bhrigesh

Reputation: 871

I think you are not reloading your table view. after completing your parsing just reload your table view.

[reload tablename];

then check your table view delegates are calling or not after this method. I think this will help you.

happy coding.

Upvotes: 2

Related Questions