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 (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