On Apr 21, 2012, at 19:18 , Koen van der Drift wrote:
> So, I solved it as follows. I created a deleteObjects IBAction in my
> AppController class invoked by the delete menuItem. To remove the objects, I
> am more or less following the code in Hillegass' book, chapter 15 on
> NSAlerts. In this example, the line
>
> [employeeController remove: nil] is used to remove the selected objects
> (employees)
>
> However in my app it didn't remove anything (the code was called, though).
> After some searching, I ended up doing the following:
>
> for (Employee *employee in employeeArrayController.selectedObjects)
> {
> [[self managedObjectContext] deleteObject: employee];
> }
>
>
> It seems to work, but just to be sure I am checking here to see if this is
> indeed the correct approach?
It's *a* correct approach.
It's not clear what went wrong with '[employeeController remove: nil]', but
that's a completely separate problem. For example, if you left the array
controller in Class mode rather than Entity mode, 'remove:' won't update Core
Data properly. Also, take a look at the class reference documentation for
NSArrayController (for the 'removeObject:' method) for a discussion of how to
configure the array controller's deletion behavior for Core Data.
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]