• 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
Custom object in core data.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Custom object in core data.


  • Subject: Custom object in core data.
  • From: Todd Freese <email@hidden>
  • Date: Mon, 20 Feb 2006 17:18:05 -0600

I am having trouble getting a custom object to save into Core Data. I have two attributes setup, one that is transient and one that is undefined. My object supports the NSCoding protocol. Here is my accessor methods:

- (TimeCodeNumber *)startTimeCode
{
// On-demand get accessor.
[self willAccessValueForKey:@"startTimeCode"];
TimeCodeNumber *timeCodeNumber = [self primitiveValueForKey:@"startTimeCode"];
[self didAccessValueForKey:@"startTimeCode"];
if (timeCodeNumber == nil) {
NSData *timeCodeNumberData = [self valueForKey:@"startTimeCodeData"];
if (timeCodeNumberData != nil) {
timeCodeNumber = [NSUnarchiver unarchiveObjectWithData:timeCodeNumberData];
[self setPrimitiveValue:timeCodeNumber forKey:@"startTimeCode"];
}
}
return timeCodeNumber;
}


- (void)setStartTimeCode:(TimeCodeNumber *)value
{
	// Immediate-Update Set Accessor
    [self willChangeValueForKey:@"startTimeCode"];
    [self setPrimitiveValue:value forKey:@"startTimeCode"];
    [self didChangeValueForKey:@"startTimeCode"];
    [self setValue:[NSArchiver archivedDataWithRootObject:value]
			forKey:@"startTimeCodeData"];
}

- (NSData *)startTimeCodeData
{
    NSData * tmpValue;

    [self willAccessValueForKey: @"startTimeCodeData"];
    tmpValue = [self primitiveValueForKey: @"startTimeCodeData"];
    [self didAccessValueForKey: @"startTimeCodeData"];

    return tmpValue;
}

- (void)setStartTimeCodeData:(NSData *)value
{
    [self willChangeValueForKey: @"startTimeCodeData"];
    [self setPrimitiveValue: value forKey: @"startTimeCodeData"];
    [self didChangeValueForKey: @"startTimeCodeData"];
}

When I try to save data into the store, I get the following error:
*** -encodeObject:forKey: only defined for abstract class. Define - [NSArchiver encodeObject:forKey:]!


Any ideas?

Todd Freese
The Filmworkers Club - Chicago
_______________________________________________
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: Custom object in core data.
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Re: NSFont reports different -capHeight in 10.4.4 than in previous OS versions?
  • Next by Date: Re: After inserting link into text, link continues as user types
  • Previous by thread: Re: Sorting array of strings by string length
  • Next by thread: Re: Custom object in core data.
  • Index(es):
    • Date
    • Thread