[SOLVED]: Re: Can a model key path binding access a super class property
[SOLVED]: Re: Can a model key path binding access a super class property
- Subject: [SOLVED]: Re: Can a model key path binding access a super class property
- From: Grant Christensen <email@hidden>
- Date: Mon, 18 Jan 2010 08:57:03 +1000
Thanks for the nudge in the right direction James... I went back to the debugger and found an underlying problem with the two variables in the base class that were not coming through. It as a mere coincidence that it was those two in the base class, and I was not setting them correctly in the first place. Always the simple answers :)
regards,
Grant
On 18/01/2010, at 3:04 AM, James Bucanek wrote:
> Grant Christensen <mailto:email@hidden> wrote (Sunday, January 17, 2010 6:53 AM +1000):
>
>> In my window I have a NSTableView that is using an array controller to get
>> access to my data. The array controller is bound to an array of
>> BBSMoreSpecific classes.
>>
>> The problem I am having is that all of my columns bound to the fields in the
>> BBSMoreSpecific class show their data, but those bound to those in the base
>> class do not. I am using a simple model key path of just the name of the
>> ivar, so aValue and anotherValue.
>>
>> Can the bindings access the base class or can they only access values in the
>> class the array controller is directly connected to?
>
> Of course you can. This is a basic principle of object oriented languages (unless there's scoping, but Objective-C doesn't support that). You could verify this by using a key-value path to access any of the object's NSObject properties, like -description.
>
> I suspect that something else is wrong. Your simplistic example appears to be valid, but it's obviously not the code you're using. It time to hit the debugger....
>
> Since you've declared these as formal properties, KVO should be accessing these properties via their accessor methods. One trick is to override the base-class getter method in your subclass like this:
>
> @implementation BBSMoreSpecific
> ...
> - (NSString*)aValue
> {
> NSString* value = [super aValue];
> //NSLog(@"%s returning '%@'",__func__,value);
> return value; // <-- set breakpoint here
> }
>
> Now you can set a breakpoint or log every access to that property. You shouldn't have any problem verifying if the correct messages are being sent (or not), by whom, and then work backwards from there.
>
> --
> James Bucanek
>
---
Grant Christensen
_______________________________________________
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