Re: NSTreeController: do leaf and non-leaf nodes have to be of the same class?
Re: NSTreeController: do leaf and non-leaf nodes have to be of the same class?
- Subject: Re: NSTreeController: do leaf and non-leaf nodes have to be of the same class?
- From: Greg Hurrell <email@hidden>
- Date: Thu, 18 May 2006 21:19:25 +0200
El 18/05/2006, a las 20:21, Ondra Cada escribió:
The best (arguably) and most convenient (definitely) solution is to
make your "group" respond to these messages, returning reasonable
default "empty" values. That're those "kludgey methods" of yours.
Ok, so I've done that, and yes I did do it as a category so as to
keep the design cleaner. In the case of text cells this looks fine
because you can return an empty string and the cells look empty
(which is the desired effect). In the case of button cells
(checkboxes) is there any way to prevent the checkboxes from
appearing at all? Or do I have to settle for disabling them so that
they appear as ghosted?
I briefly tried this and got rid of the runtime
"valueForUndefinedKey: this class is not key value coding-
compliant for the key displayName." error message; instead I got
the slightly more cryptic message: "valueForUndefinedKey: this
class is not key value coding-compliant for the key ." <-- not
that there's no key there at all!
Strange... looks like some typo somewhere or so...
Turned out to be a spurious "Bind" checkbox that was accidentally
checked for some control in the nib and which had an empty model key
path.
I tried setting a symbolic breakpoint on -[NSObject
valueForUndefinedKey:] but it doesn't really help me to figure out
what's going on as I have no idea how to interpret the content of
the registers in the debugger
Not that it is difficult (at least for PPC), but there's easier
solution to this: just implement valueForUndefinedKey: in your
class and break there.
Yes, that occurred to me after posting... the key in question was an
empty string, which goes back to that empty model key path mentioned
above.
Thanks for your help, Ondra!
I'm now having to rework my model a bit in any case because due to my
lack of experience I used an NSDictionary as the data store, and I
see that NSTreeController wants to invoke objectAtIndex: on it... it
evidently expects an ordered collection (NSArray or similar); I guess
I should have known. I mistakenly thought, "NSTableView -> ordered
list -> use arrays... NSOutlineView -> hierarchical collection -> use
dictionaries". As a temporary workaround I did the following just to
see if it would work:
@implementation NSDictionary (CrudeHack)
- (id)objectAtIndex:(unsigned)index
{
return [self objectForKey:[[[self allKeys]
sortedArrayUsingSelector:@selector(compare:)] objectAtIndex:index]];
}
@end
This works, but I'm going to go back and rework my model anyway so
that it's "done right".
Cheers,
Greg
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden