• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: core data, undo and redo - follow-up question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: core data, undo and redo - follow-up question


  • Subject: Re: core data, undo and redo - follow-up question
  • From: Martin Hewitson <email@hidden>
  • Date: Sat, 22 May 2010 19:20:31 +0200

Actually, I remembered what the other problem was that 'lead me down the wrong path'. I'm observing one of the properties of the NSManagedObject, so before I remove it from the tree-controller, I stop observing the property. Now if I undo the removal, I need a place to set up the observing again.

Can anybody recommend where I should do that? I notice that insertObject:atArrangedObjectIndexPath: of NSTreeController is not called when I undo the removal.

Best,

Martin


On May 22, 2010, at 6:54 PM, Martin Hewitson wrote:

> Thanks, Jerry. I was trying to let core data do its thing, but I was getting errors associated with the regular instance variables of the managed objects after an undo, so I started down this road of trying to somehow handle myself the releasing and re-instantiating of the instance variables. Probably I took the wrong track and I should rather try harder to figure out where the problem was, and fix that, rather than try to get around it.
>
> Thanks for the advice,
>
> Martin
>
>
>
> On May 22, 2010, at 6:50 PM, Jerry Krinock wrote:
>
>>
>> On 2010 May 22, at 09:36, Martin Hewitson wrote:
>>
>>> In particular I have an NSManagedObject subclass which has properties which are not part of the core data model, but are instead (in some sense) transient.
>>
>> I believe you're referring to what I'd call these "regular instance variables".
>>
>>> For example, one property is an NSTextStorage which I create in awakeFromFetch:. At the moment, I have to release the NSTextStorage just before I remove the item from the tree-controller. I rather expected (perhaps wrongly) that removing the item from the tree-controller (which is bound to the managed object context) would result in the particular NSManagedObject being released, but I don't see that happening.
>>
>> That's true.  Core Data will release objects when it gets good and ready, and there's no telling when that is.
>>
>>> I also checked to see if didTurnIntoFault: is called on the item, but it isn't.
>>
>> It will be called eventually.  My understanding is that any clean-up code which you'd usually put in -dealloc for a regular object should be put in -didTurnIntoFault for a managed object.  Seems to work for me.
>>
>>> My main problem is that, when I undo the removing of items from the tree, I need to reinstate the transient properties like the text storage.
>>
>> But if you didn't release them in the first place, you wouldn't need to put them back in the second place.
>>
>>> When I undo, awakeFromFetch: isn't called, neither is awakeFromInsert:. So where does one get the chance to 'handle things' after an undo? I saw in the documentation the method awakeFromSnapshotEvents: but there it says "Available in iPhone OS 3.0 and later". What about if I'm developing for 10.5?
>>
>> I think you should sit back and let Core Data do its work.
>>
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> Please 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:
>>
>> This email sent to email@hidden
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Martin Hewitson
> Albert-Einstein-Institut
> Max-Planck-Institut fuer
>    Gravitationsphysik und Universitaet Hannover
> Callinstr. 38, 30167 Hannover, Germany
> Tel: +49-511-762-17121, Fax: +49-511-762-5861
> E-Mail: email@hidden
> WWW: http://www.aei.mpg.de/~hewitson
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
    Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: core data, undo and redo - follow-up question
      • From: Kyle Sluder <email@hidden>
References: 
 >core data, undo and redo (From: Martin Hewitson <email@hidden>)
 >Re: core data, undo and redo (From: Jerry Krinock <email@hidden>)
 >Re: core data, undo and redo (From: Martin Hewitson <email@hidden>)

  • Prev by Date: Re: getting file creation date from NTFS
  • Next by Date: Re: core data, undo and redo - follow-up question
  • Previous by thread: Re: core data, undo and redo
  • Next by thread: Re: core data, undo and redo - follow-up question
  • Index(es):
    • Date
    • Thread