I am trying the following:
I have a NSView (in its own nib file), that use the NSManagedObjectContext (moc) from the main program. I want to reuse this view in multiple windows.
-(id) initWithContext🙁NSManagedObjectContext *) theMOC
{
self = [super init];
if (self){
[NSBundle loadNibNamed😡"myView"
owner:self];
//model
managedObjectContext = [theMOC retain];
NSManagedObject *mo= [NSEntityDescription insertNewObjectForEntityForName😡"myEntity"
inManagedObjectContext:managedObjectContext];
[mo setValue😡"test 1"
forKey😡"title"];
return self;
}
return nil;
}
I can load this NSView and display it in a window and add entries to the moc (in code). But the interface elements (such as a table) complain that there is no moc:
'Cannot perform operation without a managed object context'
I have checked the bindings. The arraycontroller is bound to 'theMOC'.
Any ideas?
Thanks
I have a NSView (in its own nib file), that use the NSManagedObjectContext (moc) from the main program. I want to reuse this view in multiple windows.
-(id) initWithContext🙁NSManagedObjectContext *) theMOC
{
self = [super init];
if (self){
[NSBundle loadNibNamed😡"myView"
owner:self];
//model
managedObjectContext = [theMOC retain];
NSManagedObject *mo= [NSEntityDescription insertNewObjectForEntityForName😡"myEntity"
inManagedObjectContext:managedObjectContext];
[mo setValue😡"test 1"
forKey😡"title"];
return self;
}
return nil;
}
I can load this NSView and display it in a window and add entries to the moc (in code). But the interface elements (such as a table) complain that there is no moc:
'Cannot perform operation without a managed object context'
I have checked the bindings. The arraycontroller is bound to 'theMOC'.
Any ideas?
Thanks