Maximum number of cells in UITableView
I am building an App that keeps track of your training. There is a home screen (uitableview) that features the dates of the days when you excersised. Now I only want to feature the last 20 trainings. So is there any way to put a maximum of items on an Array, or a maximum of cells in a TableView, the oldest trainings will be replaced by the newer ones.
Thanks in advance,
Ruben
Answers
Well one way to do this , if you sort the data by dates , then you can put a fix number on the datasource method:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 20; }
You haven't showed how you populate the data, if it comes from a database perhaps you can do a SELECT TOP 20 ... or LIMIT depending on the type of Db.
then return that array count:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [array count]; }