Problem With implementing copyWithZone
Problem With implementing copyWithZone
- Subject: Problem With implementing copyWithZone
- From: Thaddeus Cooper <email@hidden>
- Date: Sun, 7 Oct 2007 18:25:35 -0700
Hello All --
I have a subclass of NSManagedObject that I am trying to implement
copyWithZone in. I would have thought that this would be a simple
process based on my research in the archives of the mailing list. I
found the following snippet of code which I adapted for my own purposes:
- (id)copyWithZone:(NSZone *)zone {
id copy = [[[self class] allocWithZone:zone] init];
[copy setThisAttribute:[self getThisAttribute]];
[copy setThatAttribute:[self getThatAttribute]];
return copy;
}
My implementation looks like:
- (id) copyWithZone:(NSZone *)zone {
id copiedWine;
copiedWine = [[[self class] allocWithZone:zone] init];
// [copiedWine setVineyard:[self vineyard]];
// [copiedWine setValue:[self valueForKey:@"vineyard"]
forKey:@"vineyard"];
[copiedWine setVineyard:[self valueForKey:@"vineyard"]];
return(copiedWine);
}
When the method is called I get the following error:
2007-10-07 18:12:40.205 WineCellar[5988:10b] *** Terminating app due
to uncaught exception 'NSUnknownKeyException', reason: '[<Wine
0x174027e0> setValue:forUndefinedKey:]: the entity (null) is not key
value coding-compliant for the key vineyard.'
2007-10-07 18:12:40.206 WineCellar[5988:10b] Stack: (
2477803064,
2426327195,
2477801825,
2458935672,
2470635448,
79584,
86877,
2416367608,
2416450382,
2416450119,
2418600087,
2418598909,
2419265892,
2419265553,
2417649629,
2417136543,
2417135976,
2417133214,
2416761814,
2416756412,
2417346575,
2417341342,
2417342197,
2417342197,
2417342197,
2417342197,
2417342197,
2417342197,
2417335548,
2417333822,
2417320300,
2416538197,
2416537092,
2417304252,
2417302802,
2417506539,
2416334426,
2416293791,
2416292097,
2416291140,
2416290946,
2416290097,
9060,
8986
)
There are accessor methods in the class are defined as:
- (NSString *) vineyard;
- (void) setVineyard:(NSString *)value;
I'm not sure what I'm doing wrong here, but if anyone has a
suggestion as to how to fix this problem I would be grateful.
Thanks very much.
Thaddeus O. Cooper
(email@hidden)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden