Re: How To Unbind
Re: How To Unbind
- Subject: Re: How To Unbind
- From: Richard Somers <email@hidden>
- Date: Mon, 31 Aug 2009 12:40:26 -0600
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 (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