Re: Problem binding NSTextView's attributedString
Re: Problem binding NSTextView's attributedString
- Subject: Re: Problem binding NSTextView's attributedString
- From: Quincey Morris <email@hidden>
- Date: Thu, 31 Jul 2008 15:21:29 -0700
On Jul 31, 2008, at 14:04, Pete Callaway wrote:
I don't think I'm doing anything behind Core Data's back particularly.
"selectedPage" is a property of the NSPersistentDocument, not of an
NSManagedObject. I have several view controllers and they each need to
know which entity to show the detail of. It seemed to me that the
obvious way to do this was to maintain a pointer to the selected page
in a central location and the document seemed to be the ideal spot.
Er, sorry, I was mesmerized by those ...AccessValueForKey calls.
They're methods of NSManagedObject, so I just assumed that 'self' was
some kind of NSManagedObject. In fact, your posted implementation of
selectedPage ought to get compilation errors (including one for the
missing semi-colon at the end).
My guess (and, sorry, I'm just guessing) is that the text view is
getting bound to the string object fetched by
document.selectedPage.textContent at the time the binding is set up
(i.e. bound to key "self" of some string) instead of getting bound to
key "selectedPage.textContent" of the document. You could find out by
selecting a different page (so that the wrong text is displayed) and
then change the text and press Return. Then save and reopen the
document to find out which page (if any) actually got changed.
Plan B might be to add a NSObjectController. Bind the object
controller to the document, and bind the text view to the object
controller, controller key "selection", data model key
"selectedPage.textContent". (You kind of want to do that anyway,
because the object controller has the logic to commit the text field
if you try to close the document window while the text field is being
edited.)
_______________________________________________
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