I’m using the following code to populate a TList list…
method MonthSummaryView.tableView(tableView: UITableView) numberOfRowsInSection(section: NSInteger): NSInteger;
var
ICount: Integer;
begin
{$WARNING Potentially incomplete method implementation.}
// Return the number of rows in the section.
result := 0;
if FMonth > 0 then
begin
result := DaysInMonth(EncodeDate(FYear, FMonth, 1));
FDaysInMonth.Clear;
for ICount := 1 to result do
FDaysInMonth.Add(new DateTime(FYear, FMonth, ICount));
end;
end;
I then use this list in the cellForRowAtIndexPath method to add the dates to the table view rows…
method MonthSummaryView.tableView(tableView: UITableView) cellForRowAtIndexPath(indexPath: NSIndexPath): UITableViewCell;
begin
var CellIdentifier := “MonthSummaryCell”;result := tableView.dequeueReusableCellWithIdentifier(CellIdentifier);
if not assigned(result) then begin
result := new UITableViewCell withStyle(UITableViewCellStyle.UITableViewCellStyleDefault) reuseIdentifier(CellIdentifier);// Configure the new cell, if necessary...
end;
result.textLabel.text := FDaysInMonth[indexPath.row].ToLongPrettyDateString;
// Configure the individual cell…
end;
However, my first row is always the last date of the previous month, rather than the first day of the month I am interested in.
I will run some standalone tests but I thought I’d let you know in case this was a bug… I can’t see anything wrong with my code which would cause the date to be out by 1 day.
I will keep playing with it here to see if I can track down the issue.