Skip navigation.
 
mlRe: Two simple questions regarding Core-Data
FROM : Marcus S. Zarra
DATE : Fri May 04 19:03:16 2007

Basically, the fetch will return an array of faults if the objects are
not already in memory.  Performing a count on the array will not cause
the faults to fire since you are not accessing the attributes of the
objects inside of the array.  You are just asking the array how many
objects it holds.

Personally, I would recommend this method over keeping a count
attribute in a parent object.  It is way too easy for that count to
get out of sync with the array.  Since counting the number objects in
the relationship will not cause the faults to fire it is safer to get
this information each time it is requested.

Marcus S. Zarra
Zarra Studios LLC
Simply Elegant Software for OS X
www.zarrastudios.com


On 5/4/07, Robert Walker <<email_removed>> wrote:
> Marcus,
>
> > Again no.  Fortunately when the array is retrieved all of the objects
> > are "faults" which means they are not loaded into memory yet and your
> > call to count will not cause them to load.  Therefore the memory and
> > performance hits are negligible.
>
> Are you sure that asking for the count would not cause the fault
> representing a collection to fire?  If so that's really impressive.
> How would Core Data know the number of objects represented by the
> fault without realizing the fault first?
>
> --
> Robert Walker
> <email_removed>
>
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> Do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/<email_removed>
>
> This email sent to <email_removed>
>

Related mailsAuthorDate
mlTwo simple questions regarding Core-Data Hell's KItchen Hel… May 4, 13:25
mlRe: Two simple questions regarding Core-Data Marcus S. Zarra May 4, 18:45
mlRe: Two simple questions regarding Core-Data Robert Walker May 4, 18:47
mlRe: Two simple questions regarding Core-Data Robert Walker May 4, 18:59
mlRe: Two simple questions regarding Core-Data Marcus S. Zarra May 4, 19:03
mlRe: Two simple questions regarding Core-Data Robert Walker May 4, 22:04
mlRe: Two simple questions regarding Core-Data Marcus S. Zarra May 4, 23:08
mlRe: Two simple questions regarding Core-Data Robert Walker May 4, 23:48
mlRe: Two simple questions regarding Core-Data Steve Israelson May 5, 00:33