awakeFromFetch : when it is called ?

  • Hi List !

    I'm trying to use awakeFromFetch to initialize some properties on my
    managed object subclass and I was wondering when it was called. It is
    not the method "executeFetchRequest:..." (it works perfectly, returns
    some result, but awakeFromFetch is not called) and I don't know which
    other method could call awakeFromFetch ?

    Do I have to call it myself ?

    Oh, and awakeFromInsert works perfectly...

    Do someone know how to use awakeFromFetch ?

    Eric.

    =============================================
    Automator Ketchup : http://automatorketchup.blogspot.com
  • On Jan 15, 2006, at 1:39 PM, Eric Morand wrote:

    > I'm trying to use awakeFromFetch to initialize some properties on
    > my managed object subclass and I was wondering when it was called.
    > It is not the method "executeFetchRequest:..." (it works perfectly,
    > returns some result, but awakeFromFetch is not called) and I don't
    > know which other method could call awakeFromFetch ?

    Per <http://developer.apple.com/documentation/Cocoa/Reference/
    CoreData_ObjC/Classes/NSManagedObject.html#//apple_ref/occ/instm/
    NSManagedObject/awakeFromFetch
    >, it gets called automatically after
    an object is fetched or unfaulted...
    Check that you have spelled the method name correctly (also ensure
    that you invoke super...).

    mmalc
  • Thanks mmalcolm.

    I had some problem with the term "fetched". I thought the
    "executeFetchRquest..." method was actually a fetch. But it is not.
    The object are fecthed only when I'm trying to access its properties/
    relationships.

    It's perfect. My problem was due to the fact that I was trying to
    access a property that was not defined on the model (I added it
    myself on the class definition). So the object was NOT fetched are
    awakeFromFecth not called. I've fixed it by adding the property intot
    o the model and define it as transient. Now it is working perfectly :
    the object is fetched when I use the get/set accessors of my property.

    By the wat, are fetched and unfaulted synonyms ? It seems to me but
    there may be some subtlenesses I've not yet discover.

    Eric.

    Le 16 janv. 06 à 00:49, mmalcolm crawford a écrit :

    >
    > On Jan 15, 2006, at 1:39 PM, Eric Morand wrote:
    >
    >> I'm trying to use awakeFromFetch to initialize some properties on
    >> my managed object subclass and I was wondering when it was called.
    >> It is not the method "executeFetchRequest:..." (it works
    >> perfectly, returns some result, but awakeFromFetch is not called)
    >> and I don't know which other method could call awakeFromFetch ?
    >
    > Per <http://developer.apple.com/documentation/Cocoa/Reference/
    > CoreData_ObjC/Classes/NSManagedObject.html#//apple_ref/occ/instm/
    > NSManagedObject/awakeFromFetch>, it gets called automatically after
    > an object is fetched or unfaulted...
    > Check that you have spelled the method name correctly (also ensure
    > that you invoke super...).
    >
    > mmalc
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Cocoa-dev mailing list      (<Cocoa-dev...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/cocoa-dev/<eric.morand...>
    >
    > This email sent to <eric.morand...>

    =============================================
    Automator Ketchup : http://automatorketchup.blogspot.com
  • On Jan 16, 2006, at 12:39 AM, Eric Morand wrote:

    > I had some problem with the term "fetched". I thought the
    > "executeFetchRquest..." method was actually a fetch. But it is not.
    > The object are fecthed only when I'm trying to access its
    > properties/relationships.

    Fetched objects (that is, those that are instances of the entity that
    is fetched, and that meet the criteria given by the fetch predicate)
    are fully instantiated -- they are not faults.

    "If you execute a fetch using executeFetchRequest:error:, it always
    fetches the data and caches the results in memory. If you fire a
    fault in the result array from executeFetchRequest:error:, Core Data
    will not go back to the store. Converting a fault into a complete
    managed object is very fast with a cache hit—it is basically the same
    as normal instantiation of a managed object."

    > By the wat, are fetched and unfaulted synonyms ? It seems to me but
    > there may be some subtlenesses I've not yet discover.

    "Core Data avoids the term "unfaulting" because it is confusing.
    There's no "unfaulting" a virtual memory page fault. Page faults are
    triggered, caused, fired, or encountered. Of course, you can release
    memory back to the kernel in a variety of ways (vm_deallocate,
    munmap, sbrk). Core Data describes this as "turning an object into a
    fault"."

    <http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/
    Articles/cdFaultingUniquing.html#//apple_ref/doc/uid/TP30001202
    >

    mmalc
previous month january 2006 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today