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,



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 
    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 
    return [array count];

Need Your Help

php screws up utf-8 charachters from mysql database using mysqli

php mysql utf-8 mysqli cjk

I have some chinese characters (e.g. 中文(简体)) stored in a mysql database with content type utf8_bin.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.