-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BaseModel integration #15
Comments
Yes, you can easily implement NSCopying yourself in a subclass of BaseModel, without using AutoCoding. Just add this method to your class:
|
so i'd like your opinion on something. i have a complex stack of objects that all extend from my base class that extends first thing, your suggestion, tweaked: -(id)copyWithZone:(NSZone *)zone {
id copy = [[[self class] alloc] init];
for (NSString *key in [[self class] codablePropertyKeys]) {
[copy setValue:[self valueForKey:key] forKey:key];
}
return copy;
} some potentially extraneous logic: -(id)copyWithZone:(NSZone *)zone {
id copy = [[[self class] alloc] init];
for (NSString *key in [[self class] codablePropertyKeys]) {
if([[self valueForKey:key] respondsToSelector:@selector(copyWithZone:)]) {
[copy setValue:[[self valueForKey:key] copyWithZone:zone] forKey:key];
}else {
[copy setValue:[self valueForKey:key] forKey:key];
}
}
return copy;
} |
my class extends
BaseModel
but i'd like it to implementNSCopying
so I'm also now importingAutoCoding
. becauseBaseModel
has anuncodableProperties
class method,AutoCoding
is spitting out a whole ton ofAutoCoding Warning: uncodableProperties method is no longer supported. Use ivars, or synthesize your properties using non-KVC-compliant names to avoid coding them instead.
Is there a more appropriate way to implement
NSCopying
or should I be doing something differently? I don't have any "uncodable" properties in my classes.thanks for these awesome classes :-)
The text was updated successfully, but these errors were encountered: