Hi again folks,

of course, the IB "Deletes objects on remove" option for the People array
controller had something to do with it... sigh...

Sorry for filling up your Inboxes...
Ken

On 4 Jan 2010, at 10:14, Tabb, Ken wrote:

Hi folks & Happy New Year,

I'm not sure why this is a problem as I've done this before now, so
can't quite see the problem. This is all on 10.6.2 in a Core Data app
(i.e. non-document-based). Despite re-reading the Core Data
Programming Topics & Marcus Zarra's (excellent) book, I'm stumped as
to why I'm getting the problem I am.

I've distilled it into a sample app with XML store, so I can 'read'
the store etc.

In the sample app I have Department and Person objects. Department has
an optional to-many relationship 'people', with a cascade delete rule.
Person has a non-optional to-one relationship 'department' (which is
the inverse of the other relationship), with a nullify delete rule.

If I add a new person in a given department, all is well (app can be
quit / relaunched, everything is as it should be). If I then remove
that person, all seems well. Until the store tries to save, at which
point I get a "department is a required value" error. I then "quit
anyway", relaunch, and the person is back from the dead.

If I make the person's 'department' relationship optional, then it's
quite happy saving the store after I delete a person. However if I
then open up the XML store, the person is lingering on in cryogenic
storage, with no owning department, i.e. they were removed from the
department, but not deleted from the store. Bearing in mind this is
after the app has quit, so can't be the Undo manager etc. retaining
them for its own needs.

The button doing the removing is hooking up to the 'remove' action of
the People array controller, which in turn binds its content set to
the Departments array controller (controller key = selection, model
key path = people).

So it seems the array controller is not trying to remove the Person
object, but just trying to break its relationship to its containing
Department.

I'm missing something brain-numbingly obvious aren't I? :)

Thanks in advance for pointing out my stupidity,

Ken

p.s. I've checked and the app delegate is definitely using
NSXMLStoreType, not NSCryogeneticStoreType ;)

- - - - - - - - - -
Dr. Ken Tabb
Mac & UNIX Developer - Health & Human Sciences
Machine Vision & Neural Network researcher - School of Computer
Science
University of Hertfordshire, UK


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/k.j.tabb
%40herts.ac.uk

This email sent to k.j.t...@herts.ac.uk

- - - - - - - - - -
Dr. Ken Tabb
Mac & UNIX Developer - Health & Human Sciences
Machine Vision & Neural Network researcher - School of Computer Science
University of Hertfordshire, UK


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to