• 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
Deallocating Core Data objects in a document-based app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Deallocating Core Data objects in a document-based app


  • Subject: Deallocating Core Data objects in a document-based app
  • From: Jonathan Fewtrell <email@hidden>
  • Date: Fri, 2 Nov 2007 16:31:53 +0000

I am working on a Core Data document-based app. I cannot get the managed objects to deallocate when I close a document. I have the feeling that the problem is circular references. Or it could be bindings.

The managed objects have various one-to-one and one-to-many relationships to other instances of the same entity, which would certainly create circular references because of the requirement to model both sides of the relationship. But my understanding was that these would automatically be cleared up by Core Data when the document was closed. I further understand that if objects outside the CD graph retain any of the managed objects I need to break these 'cross-border' links myself. Now in my case, I do cache a number of the fetched managed objects in an NSArray. I may have read the documentation wrong, but my impression was that if I released this array, thereby removing the only cross-border reference, CD would then be able to take over and clear up and deallocate the managed objects as thought the NSArray had never existed. I release it in - windowWillClose: but the model objects are not deallocated.

I also clear the undo stack, as mentioned elsewhere in the documentation and on this list. Makes no difference.

I assume that the CD framework will fault the managed objects when it closes a document. But in case it doesn't, I faulted them myself. Again, no difference. As an alternative, I tried sending -reset to the managed object context. This results in messages that when releasing an object in an autorelease pool, the object was found to have been invalidated.

Are there further steps that I need to take?

As regards bindings, I am a little confused as to whether the old problem of binding to File's Owner has gone away. File's Owner is my NSPersistentDocument subclass. Do I need to unbind things that are bound to it or not? Apple's sample apps suggest not, but some posts on this list suggest otherwise. I have tried, and the result is crashes. Any clarification on where things stand on this issue would be appreciated. I am using XCode 2.4.1 and targeting OS X 10.4.
_______________________________________________


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


  • Prev by Date: Re: [Leopard] Core Data model versioning vs. NSPersistentDocument
  • Next by Date: Re: Best practice for hidden keyboard shortcuts
  • Previous by thread: Re: Transparent divider
  • Next by thread: Printing and view bounds
  • Index(es):
    • Date
    • Thread