I'm using a core data, NSFetchedResultsController UITableView, with a transient NSDate attribute. The main reason I have this as a transient property is so my UITableView entries get put into sections based on NSDate, but can move between the sections when the date changes.
So far it seems to work great, but it only updates/refreshes (I'm really new to this, so I don't know if I'm using the correct terminology, sorry!) when I either close the app and kill it from multitasking, or re-run it through Xcode. If I don't do that, the items don't change and aren't put into their correct sections. Is there a way to manually get it to refresh so the user doesn't need to do that to get it to run right?
Thank you!
Transient properties are refreshed when you send a
refreshObject:mergeChanges:
to your object.The solution provided by Mundi to apply key value observing mechanism might work too and if it does, it is definitely much more convenient than refreshing explicitly.
First, make sure that you transient property is only used for the
sectionNameKeyPath
when creating your fetched results controller. Best name itsectionIdentifier
(as Apple does in their sample code.) The actual date should be a separate attribute of your entity. (I will call itdateAttribute
.Second, make sure that you specify the key path dependencies in your Entity.m file:
Third, make sure that in your controller, you react appropriately to changes in the managed object context through
If anything is unclear, take a look at the Apple example DateSectionTitles.