Skip navigation.
 
mlRe: .. Newbie: KVO question
FROM : Matt Neuburg
DATE : Mon Aug 14 19:36:04 2006

On Sun, 13 Aug 2006 21:12:05 -1000, Peter Sampson <<email_removed>> said:
>Hello,
>
>I have a model class, Book.
>
>I want to set the "title" property of that class on insertion, with a
>default value.
>
>Created everything to be KVO compliant, no problems until I try to
>setValue: forKey: on add: (via NSArrayController.
>
>Here's what I did:
>
>- correctly set accessor methods;
>- subclass NSArrayController and pointed to the custom class in IB;
>- Override add: method as below:
>
>- (void) add:(id)sender {
> [super add:sender];
> NSLog(@"New Object.");
> [self setValue:@"Great Book Title" forKey:@"title"];
> return self;
>}
>
>Message gets sent, and NSLog prints. However, I get this error:
>
>setValue:forUndefinedKey:]: this class is not key value coding-
>compliant for the key title.


The reason you're having trouble diagnosing the problem is that the phrase
"this class" used in the log message is not providing enough information.
"self" is your NSArrayController subclass. It is not his "title" you want to
set, but rather that of the newly added Book object. m.

--
matt neuburg, phd = <email_removed>, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>

Related mailsAuthorDate
ml.. Newbie: KVO question Peter Sampson Aug 14, 09:12
mlRe: .. Newbie: KVO question joe OneNinetyTwo Aug 14, 10:09
mlRe: .. Newbie: KVO question mmalc crawford Aug 14, 17:39
mlRe: .. Newbie: KVO question Matt Neuburg Aug 14, 19:36