not key value coding-compliant
not key value coding-compliant
- Subject: not key value coding-compliant
- From: David Alter <email@hidden>
- Date: Tue, 11 Jul 2006 16:20:12 -0700
I want to store NSImages in core data. To do this I did the following
1) In my data model I set the attribute type to be "Binary Data"
2) In the sub class of my NSManagedObject I added some methods
- (void)setArtwork:(NSImage *)value
{
[self willChangeValueForKey: @"artwork"];
[self setPrimitiveValue: value forKey: @"artwork"];
[self didChangeValueForKey: @"artwork"];
}
- (NSImage *)artwork
{
NSData * tmpValue;
[self willAccessValueForKey: @"artwork"];
tmpValue = [self primitiveValueForKey: @"artwork"];
[self didAccessValueForKey: @"artwork"];
return tmpValue;
}
- (void)willSave
{
NSImage *tmpImage = [self primitiveValueForKey:@"artwork"];
if (tmpImage != nil) {
[self setPrimitiveValue:[NSArchiver
archivedDataWithRootObject:tmpImage] forKey:@"artworkData"];
} else {
[self setPrimitiveValue:nil forKey:@"artworkData"];
}
[super willSave];
}
- (void)awakeFromFetch
{
NSData *imageData = [self valueForKey:@"artworkData"];
if (imageData != nil) {
NSImage *image = [NSUnarchiver
unarchiveObjectWithData:imageData];
[self setPrimitiveValue:image forKey:@"artwork"];
}
}
3) I did a quick interface in IB and used Binding to link things up .
4) The data gets loaded from and external data source the first time
the application runs.
When i run it and try to save the persistent store I get "This class
is not key value coding-compliant for the key artworkData" Do I need
to have a "setArtworkData:(NSData*)" and "(NSData*)artworkData"
method in my subclass of NSManagedObject? Or is there another peace
of this I'm missing.
thanks for the help
-dave
_______________________________________________
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