R – What does it mean that a fetched property is static and not dynamically updating itself

core-datafetched-propertyiphone

Apple says in the NSFetchedPropertyDescription class reference:

Note, however, that unlike a playlist
a fetched property is static—it does
not dynamically update itself as
objects in the destination entity
change.

Nice, but what exactly does that mean: static property? Not dynamically updating in the destination entity change?

Can someone explain that?

What I get in my head is that a fetched property is for weak references. Like: A playlist may reference songs, but the playlist doesnt "own" them. If the playlist gets deleted, the song's never get deleted as a consequence of that. Also, the songs have no back-reference to the playlist, they don't have to know that it even exists.

Ok, so if a song gets deleted, the playlist isn't notified in any way? Or what is Apple trying to tell me?

Best Answer

Essentially it means that you have to manually update the fetched result every time to receive the latest changes of your source object.

I just consulted your quoted documentation. The next paragraph after your quote should make it clear:

The effect of a fetched property is similar to executing a fetch request yourself and placing the results in a transient attribute, although with the framework managing the details. In particular, a fetched property is not fetched until it is requested, and the results are then cached until the object is turned into a fault. You use refreshObject:mergeChanges: (NSManagedObjectContext) to manually refresh the properties—this causes the fetch request associated with this property to be executed again when the object fault is next fired.

Related Topic