Newbie Problem with KVC compliance
Newbie Problem with KVC compliance
- Subject: Newbie Problem with KVC compliance
- From: shaun bear <email@hidden>
- Date: Thu, 26 Oct 2006 19:22:12 +0200
I am a newbie to Cocoa programming and am trying to make sense of
CoreData and bindings. I have run in to a problem. I am trying to set
a value for a sub-class of ManagedObject: Orders which is mapped to
an Entity: Orders. I have created and instantiated a class:
DownloadController, in interface builder, that responds to a a button
click.
I want to create an instance of the Orders class and the set value
for an attribute: message. It compiles OK but when I run it and click
the button I get the following message: "...<Orders 0x3a9270>
setValue:forUndefinedKey:]: this class is not key value coding-
compliant for the key message. "
Having created this and set the values for the attributes for I then
want to add the object to the Orders Array Controller I have created
in interface builder.
I suspect I am missing something obvious but have not been able to
find code examples that do what I am attempting to do. I have
included code snippets below. Any help will be much appreciated.
code snippet Orders.h
#import <CoreData/CoreData.h>
@interface Orders : NSManagedObject
{
}
- (void)setMessage:(NSString *)value;
code snippet Orders.m
- (void)setMessage:(NSString *)value
{
[self willChangeValueForKey: @"message"];
[self setPrimitiveValue: value forKey: @"message"];
[self didChangeValueForKey: @"message"];
}
code snippet DownloadController.h
#import <Cocoa/Cocoa.h>
@interface DownloadController : NSObject
{
IBOutlet id Download;
}
- (IBAction)Download:(id)sender;
@end
code snippet DownloadController.m
- (IBAction)Download:(id)sender
{
Orders *orders = [[ Orders alloc ]init];
[orders setValue: @"o" forKey: @"message"];
}
_______________________________________________
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