Re: Programmatic Binding KVC KVO
Re: Programmatic Binding KVC KVO
- Subject: Re: Programmatic Binding KVC KVO
- From: Richard Somers <email@hidden>
- Date: Wed, 4 Nov 2009 13:17:00 -0700
On Nov 4, 2009, at 9:40 AM, Kyle Sluder wrote:
Nib 2 only partly works. Changes made in the custom view do not
show up in the managed object model or in the user interface found
in nib 1.
So now we also need to see your custom view code.
Here is the code for nib 2 which only partly works. Changes to the
model property num are reflected in the custom view but changes to the
num property in the custom view do not show up in the model.
All code in the custom view that touch the num property use the
accessor methods. The controller in the nib is in entity mode and
bound to File's Owner (MyDocument) managed object context.
@interface MyView : NSView
{
double num;
}
@end
@implementation MyView
- (double)num
{
return num;
}
- (void)setnum:(double)newNum
{
[self willChangeValueForKey:@"num"];
num = newNum;
[self didChangeValueForKey:@"num"];
}
@end
@interface MyDocument : NSPersistentDocument
{
IBOutlet MyView *myView;
IBOutlet NSObjectController *controller;
}
@end
@implementation MyDocument
- (void)windowControllerDidLoadNib:(NSWindowController
*)windowController
{
[super windowControllerDidLoadNib:windowController];
[myView bind:@"num" toObject:controller
withKeyPath:@"selection.num" options:nil];
}
@end
Thanks for looking at this.
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