5

I've enclosed a screen dump to make things easier to follow.

I've attached my outlets for datasource and delegate and I've created an outlet for my table view, but reloadData doesn't work?

Ideally I'd like to only call reloadData after the view has been loaded once?

alt text

ynnckcmprnl
  • 4,382
  • 1
  • 24
  • 25
Jules
  • 7,568
  • 14
  • 102
  • 186

2 Answers2

6

Create a property for your UITableView and use the property as your IBOutlet, using the ivar directly isn't the way to do it. Hook things up again and debug it, to see if your UITableView isn't nil.

Put a breakpoint in the UITableView datasource methods to see if they get called, if they are, check if your transactionsArray actually contains items.

If this doesn't help, you'll have to provide more info like which methods are being called and more code.

ynnckcmprnl
  • 4,382
  • 1
  • 24
  • 25
  • Check if your array actually contains new/updated data when your reloadData is called. – ynnckcmprnl Oct 01 '10 at 08:49
  • I've done some debugging, the array is updated but cellForRowAtIndexPath does't get called, on return to the view. As i say, it does run the first time when the view is loaded, but not afterwards. – Jules Oct 01 '10 at 08:55
  • 1
    Ahhh I need to remove if (cell == nil) { – Jules Oct 01 '10 at 09:43
  • 1
    i think if we are removing the comment if(cell == nil) it will cause memory leak. So only move the portion of code which is changing the data out of this if loop. – Priyanka V Apr 06 '12 at 10:32
2

If the main view of your UITableViewController is your table view, you can avoid using IBOutlets and use directly the tableView property of your controller. Like this:

[self.tableView reloadData];

MaxFish
  • 449
  • 3
  • 7
  • Ok, I've changed to self.tableview, I left the poperty, outlet in place, do I need to hook something else up in IB ? also looking at examples I've seen the datasource and delegate don't seem to be hooked up, as shown in the screen dump, I have hooked them up. – Jules Oct 01 '10 at 08:43
  • Looking at your screenshot again I see that you have a UITableView inside a generic UIView. This may cause problems. I suggest you to make your controller a generic UIViewController that implements TableViewDelegates. The view outlet should be set to the main UIView, and (as you have done) an outlet should point to your UITableView. Sets the reference outlets again to your controller and retry. – MaxFish Oct 01 '10 at 09:00
  • If the new row is added then the tableView is being reloaded, be sure that the data correctly chenges after the edit. – MaxFish Oct 01 '10 at 09:31
  • Ahhh I need to remove if (cell == nil) { – Jules Oct 01 '10 at 09:42
  • Same issue i am facing, but i have use @property (nonatomic, strong) IBOutlet UITableView *HomeFeedTableView; – Piyush Apr 08 '14 at 06:27