Overview
I have an iOS project using core data (NSFetchedResultsController
) and table view. I have a field called "joingDate".
I have a set of labels on the table view cell to represent the data.
If the joiningDate is today / tomorrow, then I would like to display as "today" or "tomorrow" instead of specifying the actual date.
I was just thinking, I would check for the lastCheckedDate (last time when the date was checked) and if it over a day, then I would have to update all those labels in the rows which have a joining date and "today" or "tomorrow".
In the database the "JoiningDate" would be stored as a Date, only the label needs to display "today" / "tomorrow" / date in a specific format.
I have implemented, the following method, where the label "joingDateComments" is updated based on it's current date.
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
Question
Note - I am using NSFetchedResultsController
joiningDate
as today / tomorrow ?NSFetchedResultsController
.JoingDateComments
, so that the those records would automatically be refreshed by the NSFetchedResultsControllerAnswer:
Pls go through Andrew's comments.
user1046037,
This really isn't a Core Data question but a UITableView question. Most everything is handled in the -tableView:cellForRowAtIndexPath:
method. There you will choose how you represent the cell. The other place will be when the NSFetchedResultsController
calls you with the changed objects. (The standard Core Data table view controller writes this boiler plate for you.) In other words you should not have to loop over all of your objects. If you want finer grain control of when these cells are updated, you can listen for the did save notification. Then query the tableView for the array of visible cells. The cell index paths can then be used with to update the cell contents.
Andrew