Re: NSArrayController in entity mode and permutations (CoreData question)
Re: NSArrayController in entity mode and permutations (CoreData question)
- Subject: Re: NSArrayController in entity mode and permutations (CoreData question)
- From: Quincey Morris <email@hidden>
- Date: Mon, 12 Apr 2010 09:51:53 -0700
On Apr 12, 2010, at 08:15, vincent habchi wrote:
> I'd like to change the place of a NSManagedObject stored in a NSArrayController in entity mode (after a drag'n drop operation). I didn't find any suitable primitive, so I decided to go something like "removeAtSomeIndex" and then immediately after "insertAtSomeOtherIndex".
>
> However, it does not work: it seems as soon as an object is removed from the array, core data is told to unlink it, so, at the end of the permutation, I end up with an array full of object that get removed in core data at a later point, and after a while I get faults with non-existent objects.
This is likely NOT a Core Data question. Most likely you're not doing your memory management quite correctly. Look here under the heading "Mutable Arrays":
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Collections/Articles/Arrays.html#//apple_ref/doc/uid/20000132-BBCCJBIF
In particular, it says:
"In a managed memory environment, when an object is removed from a mutable array it receives a release message. This means that if an array is the only owner of an object, then the object is deallocated when it is removed. If you want to use the object after its removal, you should therefore typically send it a retain message before it’s removed from the array."
_______________________________________________
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