Re: Problem binding NSTextView's attributedString
Re: Problem binding NSTextView's attributedString
- Subject: Re: Problem binding NSTextView's attributedString
- From: "Pete Callaway" <email@hidden>
- Date: Thu, 31 Jul 2008 22:04:15 +0100
On Thu, Jul 31, 2008 at 9:42 PM, Quincey Morris
<email@hidden> wrote:
> On Jul 31, 2008, at 13:02, Pete Callaway wrote:
>
>> - (void)setSelectedPage:(PageEntity*)newPage
>> {
>> if (newPage == _selectedPage)
>> return;
>>
>> [self willChangeValueForKey:@"selectedPage"];
>> _selectedPage = newPage;
>> [self didChangeValueForKey:@"selectedPage"];
>> }
>>
>> - (PageEntity*)selectedPage
>> {
>> // Probably OTT
>> [self willAccessValueForKey:@"selectedPage"];
>> PageEntity *page = _selectedPage;
>> [self didAccessValueForKey:@"selectedPage"];
>>
>> return page
>> }
>
> So this is a Core Data application? If so, is "selectedPage" a property
> defined in the Core Data model, or not?
Yes it is a Core Data application. selectedPage is not defined in the
Core Data model. It's just meant as a pointer to the currently
selected page entity.
> If it is, you probably should be using primitiveSelectedPage and
> setPrimitiveSelectedPage to access your instance variable. If not, you're
> using a property behind Core Data's back, and I didn't have great success
> when I tried doing that -- though I expect it is doable and I was just Doing
> It Wrong. (Also, will/didAccessValueForKey makes no sense for properties not
> in the Core Data model, AFAIK.)
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.
> Or, you may be looking in the wrong place for the problem. Are you sure that
> PageEntity is KVO compliant for the property "stringContent"?
PageEntity is definitely KVO compliant for the "stringContent"
property. I can update this property via the bound NSTextView but if
the document's selectedPage property changes, the view doesn't update
to show it's "stringContent".
Cheers,
Pete
_______________________________________________
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