On Aug 31, 2009, at 7:05 AM, Klaus Backert wrote:

Have you tried the constant NSManagedObjectContextBinding defined in NSKeyValueBinding.h instead of your constant @"managedObjectContext"? I don't know, but may be NSManagedObjectContextBinding does not contain this string.

The problem was unbind was insufficient to de-couple the controller from its content binding. The controller content must also be set to nil. (Refer to Apple Cocoa Bindings Programming Topics, Providing Controller Content, De-coupling a Controller from its Content Bindings.) Also using NSManagedObjectContextBinding rather than @"managedObjectContext" for the controller as suggested is cleaner.

Part of the problem here is that the documentation (Apple Cocoa Bindings Reference) for NSArrayController lists the managedObjectContext under "Parameters Bindings". You would think that it should be listed under "Controller Content Bindings" or "Controller Content Parameters Bindings" because it provides controller content.

Here is the code that works.

     NSArrayController *controller;

Establish a binding programmatically.

     [controller bind:NSManagedObjectContextBinding
             toObject:self
          withKeyPath:@"managedObjectContext"
              options:nil];

Unbind programmatically.

     [controller unbind:NSManagedObjectContextBinding];
     [controller setManagedObjectContext:nil];

Richard

_______________________________________________

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