Shanison
Shanison

Reputation: 2295

Three20 TTTableViewController reload data

How can I reload the data in the TTTableViewController? I tried to call reloadData but it doesn't display the new data. I have created the datasource file, which is a subclass of TTListDataSource. Basically, the init function looks like this.

- (id) initWithObject:(NSArray *)objects { 
        if (self = [super init]) { 
                NSMutableArray *priceItems = [[[NSMutableArray alloc] init]  autorelease]; 
                for (int i = 0; i < [objects count]; i++) { 
                        [priceItems addObject: 
                         [PriceItem itemWithName: 
                                [[objects objectAtIndex:i] objectAtIndex:0] 
                                          lastDone:[[objects objectAtIndex:i] objectAtIndex:1] change:[[objects objectAtIndex:i] objectAtIndex:2]]];                                                                                           
                } 
                self.items = [NSArray arrayWithArray:priceItems]; 
        } 
        return self;  }

After the view is loaded, i start to streaming some data, thus the objects passed to initWithObject is changed, so I call 'reload' in the subclass of the TTTableViewController in order to update the data, but the data is not updated. It doesn't work for refresh method too. Do I need to implement any other method in the subclass of TTListDataSource?

Upvotes: 0

Views: 1237

Answers (2)

Yer00n
Yer00n

Reputation: 123

Try

[self invalidateModel];

That should do the trick.

Upvotes: 3

CocoaBob
CocoaBob

Reputation: 543

invalidateModel will rebuild the model, that's not efficient.

Try [TTTableViewController refresh], your table will be reloaded.

Upvotes: 1

Related Questions