Re: Should I set Core Data dependent key in the primary's setter?
Re: Should I set Core Data dependent key in the primary's setter?
- Subject: Re: Should I set Core Data dependent key in the primary's setter?
- From: Scott Ellsworth <email@hidden>
- Date: Thu, 18 Aug 2005 09:11:58 -0700
On Aug 18, 2005, at 2:23 AM, mmalcolm crawford wrote:
On Aug 17, 2005, at 5:06 PM, Scott Ellsworth wrote:
The basic idea is that, any time Core Data tries to access the
transient attribute, it will call your getter, which will handle
the calculation.
Based on some experimentation, this does not work for a SQL
store. It appears that Core Data will not call the getter on the
in-memory objects when they have a transient attribute.
I added the tradeBetweenAlongRoute transient property, a float, to
my model, and marked it transient.
I added a sort descriptor on the key "tradeBetweenAlongRoute".
This descriptor works great when applied using
sortedArrayUsingPredicate, as the fetch is then in memory, but
when I did this against a saved SQL store, I got the error
'unknown keypath tradeBetweenAlongRoute'
<http://lists.apple.com/archives/Cocoa-dev/2005/Aug/msg00797.html>
The sad thing is that I remember reading that post, but had forgotten
it when composing my reply.
Please file a documentation enhancement request to cover this.
Will do.
Am I overlooking something?
Perhaps, or perhaps my own knowledge is wrong. I had thought that
transient attributes were not kept in the persistent store, and
that fetch requests in a SQL store would be carried out against
the persistent data, thus making transient attributes
inappropriate for much of anything in a SQL store.
Transient attributes are still useful with a SQL store to represent
"non-standard" attributes (see <http://developer.apple.com/
documentation/Cocoa/Conceptual/CoreData/Articles/
cdNSAttributes.html>), and to represent other attributes that may
be cached to avoid expensive recalculation.
That came across harsher than I intended - apologies.
A better phrasing might have been 'transient attributes are only
appropriate in a SQL store for attributes to be used in-memory, or
the special cases mentioned in <cdNSAttributes.html>. Those special
cases do make sense, and I even have a few; they are just not what I
need to do for my current application.
Scot
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden