• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
not key value coding-compliant
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: not key value coding-compliant
      • From: mmalc crawford <email@hidden>
  • Prev by Date: Re: Best way to discover resource forks?
  • Next by Date: scrolling NSTextView over NSImageView
  • Previous by thread: Re: Getting added object with KVO
  • Next by thread: Re: not key value coding-compliant
  • Index(es):
    • Date
    • Thread