Re: .. Newbie: KVO question
Re: .. Newbie: KVO question
- Subject: Re: .. Newbie: KVO question
- From: Matt Neuburg <email@hidden>
- Date: Mon, 14 Aug 2006 10:36:04 -0700
- Thread-topic: .. Newbie: KVO question
On Sun, 13 Aug 2006 21:12:05 -1000, Peter Sampson <email@hidden> 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@hidden, <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>
_______________________________________________
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