wanovak
wanovak

Reputation: 6127

Updating UITableViewDelegate not on draw

I have a class definition as follows:

@interface ClassViewController : ContentViewController <UITableViewDelegate,
UITableViewDataSource> {
    IBOutlet UITableView* mTableView;
    NSMutableArray *feeds;
    NSMutableData *responseData;
}
@property (nonatomic, retain) UITableView* mTableView;
@property (nonatomic, strong) NSMutableArray* feeds;
@property (nonatomic, strong) NSMutableData* responseData;

I'm trying to load contents after a JSON request. However, the table doesn't update with the new contents until after I manipulate the screen (e.g., scroll down).

I am using [self->mTableView reloadData]; to no effect. Also, in:

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

I'm setting:

self.mTableView = tableView;

Otherwise the results don't propagate to the table at all.

Is there something I'm missing, or should that self.mTableView definition be placed elsewhere?

I'm new to Objective-C and iOS development, so if I'm leaving something out, please let me know.

Upvotes: 0

Views: 93

Answers (1)

FluffulousChimp
FluffulousChimp

Reputation: 9185

You should:

(1) Connect mTableView to the table view object in Interface Builder.

(2) Note that you can just use property notation self.mTableView rather than self->mTableView.

(1) will fix your problem. (2) is just a style issue (mainly).

enter image description here

Upvotes: 1

Related Questions