Fw: NSObjectController and Core Data
Fw: NSObjectController and Core Data
- Subject: Fw: NSObjectController and Core Data
- From: "Kevin" <email@hidden>
- Date: Wed, 14 Feb 2007 20:50:22 +0000
- Importance: Normal
- Sensitivity: Normal
Has anyone seen the behavior I've described below. See original post below.
I posted this question recently but didn't get any replies. I'm at a loss as to what the problem is.
Any insight is appreciated.
Sent via BlackBerry from Cingular Wireless
-----Original Message-----
From: Kevin <email@hidden>
Date: Tue, 13 Feb 2007 14:23:35
To:email@hidden
Subject: NSObjectController and Core Data
I'm having a couple of different problems with NSObjectControllers
and NSTextViews in my Core Data application.
Here's my setup: I have a custom NSView which displays a variable
number of NSTextViews that are created dynamically. Each of these
text views is bound to an NSObjectController. Each NSObjectController
is bound to a distinct NSManagedObject. The custom view is driven
using the row that is currently selected in an NSTableView (backed by
an NSArrayController).
I'm using an InMemoryStore with two main Entities: Item and
Attribute. Item has a to-many relationship with Attribute. Items are
managed by the NSArrayController and Attributes are managed by
individual NSObjectControllers.
Problem #1:
When I select a row in the table view, the text doesn't show up right
away in the text views. So, if I have 3 text views in my custom view,
I can see them slowly being populated when I select a row.
Problem #2:
When I edit the contents in any of the text views and then decide to
save my managed object context WITHOUT leaving the text view, the
changes are not recorded. If I leave the text view, the changes do
get recorded.
Here's the code in my custom view where I create the
NSObjectControllers and NSTextViews:
// Get attribute
NSManagedObject *attribute = ...
// Create controller
NSObjectController *controller = [[[NSObjectController alloc]
initWithContent:nil] autorelease];
[controller bind:@"managedObjectContext" toObject:[NSApp delegate]
withKeyPath:@"managedObjectContext" options:nil];
[controller setFetchPredicate:[NSPredicate predicateWithFormat:@"self
== %@", attribute]];
[controller setEntityName:@"Attribute"];
[controller fetch:self];
[objectControllers addObject:controller];
// Create text view and bind to controller
NSTextView *textView = [[[NSTextView alloc] initWithFrame:NSMakeRect
(10, y, 100, 20)] autorelease];
[textView setRichText:NO];
[textView bind:@"value" toObject:controller
withKeyPath:@"selection.text" options:nil];
[self addSubview:textView];
- Kevin
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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