Re: Proper KVO with NSTreeController + NSOutlineView
Re: Proper KVO with NSTreeController + NSOutlineView
- Subject: Re: Proper KVO with NSTreeController + NSOutlineView
- From: Joe Wollard <email@hidden>
- Date: Fri, 28 Sep 2012 08:48:07 -0400
On Sep 28, 2012, at 8:33 AM, Alex Zavatone <email@hidden> wrote:
>
> On Sep 27, 2012, at 10:42 PM, Joseph M. Wollard wrote:
>
>> I'm pretty sure I'm doing something wrong here. I have an NSTreeController bound to the 'value' of an NSOutlineView's table column. The NSTreeController's content is then bound to a property of one of my classes which feeds it an appropriate hierarchy of NSMutableDictionary objects. So, dict -> tree -> outline. All data is being displayed beautifully in the outline view.
>>
>> I'd like to observe a notification when a user edits (renames) an item in the outline view that tells me the old and new values. I'm getting notifications, but the old and new values are always null. For what it's worth, I'm currently observing the "content.name" key path of the NSTreeController instance - not sure if that makes a difference.
I think you're spot on with that one. I didn't realize that until after I sent this email last night, however I'm still not sure how to solve the issue (a.k.a. determine the correct key path). Here's an example of my data structure:
(
{
"name":"Boys",
"child": (
{
"name":Bill",
"child": ()
},
{
"name":"Steve",
"child":()
}
)
},
{
"name":"Girls",
"child": (
{
"name":"Anna",
"child":()
},
{
"name":"Bella",
"child":()
}
)
}
)
In my outline view, "Girls" and "Boys" are group headings and are immutable. However, I want the names, "Anna", "Belle", "Bill" and "Steve" to be mutable (which they are), but *those* are the properties I need to observe. Given that this structure is in an NSTreeController, what is the proper keypath for something like this? I'm pretty sure I just don't know the syntax, because it seems like it should be something like "email@hidden", but when I do that I'm pretty sure I can hear the notification center giggling at me somewhere off in the distance.
>>
>
> Seems like there's something that's not being passed, observed or called properly. Unlike when calling a unimplemented method in an object which crashes Objective C, I've found out that notifications of the wrong method name don't crash, but simply act as if nothing has happened. What has happened was that a notification was issued, but the method might have been misspelled and the program merrily continues without crashing but without telling you that there was no method to intercept and process that notification. That happened to me a few weeks ago. That doesn't sound like your problem, but thought that might help.
>
> But, if the observed and new values are null, I'd guess that your reference to content.name isn't the correct reference to the object. Try tracing through the debugger to see where it thinks it's getting the value from.
>
>
_______________________________________________
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