Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programmatic Binding KVC KVO



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Programmatic Binding KVC KVO (From: Richard Somers <email@hidden>)
 >Re: Programmatic Binding KVC KVO (From: Kyle Sluder <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.