Reputation: 6357
I have a UIViewController with one UITableView in it. The table view holds a list of favorites that can be changed by other parts of the app. I am using NSNotificationCenter to trigger the table view's reloadData method. The table view has an outlet declared as follows:
@property (strong,nonatomic) IBOutlet UITableView *faveTableView;
and synthesized as follows:
@synthesize faveTableView;
The delegate and datasource properties of the table view are set in the view controller's viewDidLoad as follows:
[self.faveTableView setDataSource:self];
[self.faveTableView setDelegate:self];
The NSNotificationCenter causes the following method to fire:
-(void)reloadNotificationReceived{
[self loadData];
[self.faveTableView reloadData];
}
loadData updates the data source which is NSMutableArray of managed objects and is working as it should.
When the view controller loads, cellForRowAtIndexPath is fired as it should be. However, when the notification is received, reloadNotificationReceived is fired and two of the table view delegate methods (numberOfRowsInSection and numberOfSectionsInTableView) ARE fired. However, cellForRowAtIndexPath is NOT fired. numberOfRowsInSection IS returning the correct number of items.
Can anyone offer up a reason why cellForRowAtIndexPath does not get fired here? Thanks!
Upvotes: 0
Views: 248
Reputation: 668
Perhaps you have set the delegate/datasource of the tableview to your controller in the storyboard/xib, but you haven't wired up the "faveTableView" tableview IBOutlet
of the the controller... If the del/datasource are set, then the it will successfully get data from the controller, but without the IBOutlet
being set, the self.faveTableView
will remain nil and hence [self.faveTableView reloadData]
won't do anything. Put a breakpoint in your viewDidLoad
and check whether the self.faveTableView
is not nil...
Upvotes: 0