-
Notifications
You must be signed in to change notification settings - Fork 79
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
Add NSCopying support to FEMMapping #74
Add NSCopying support to FEMMapping #74
Conversation
I have changed base branch to master, because develop is no longer in use. |
It also looks like a shallow copy and may cause unexpected behavior when Mapping A gets copied and later attributes updates somehow. Would you be mind to add copying support to Attribute and Relationship as well? Sorry for not mentioning it before. |
088aa37
to
8dbf482
Compare
Current coverage is 92.67% (diff: 0.00%)@@ master #74 diff @@
==========================================
Files 27 27
Lines 3068 3099 +31
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
Hits 2872 2872
- Misses 196 227 +31
Partials 0 0
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After two minor fixes look good to merge.
#pragma mark - NSCopying | ||
|
||
- (instancetype)copyWithZone:(NSZone *)zone { | ||
FEMMapping *mapping = [[self.class allocWithZone:zone] initWithEntityName:self.entityName]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to use
if (self.entityName != nil) {
= [self.class ....] initWithEntityName:];
else {
= [self.class ....] initWithObjectClass:];
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also assignment of objectClass
below needs to be removed in favor of using initializers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replaced with conditional initialiser call
|
||
- (instancetype)copyWithZone:(NSZone *)zone { | ||
FEMMapping *mapping = [[self.class allocWithZone:zone] initWithEntityName:self.entityName]; | ||
mapping.objectClass = self.objectClass; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to override setters and nil-out counterpart. Otherwise you can set both objectClass
and entityName
which might look strange
- (void)setEntityName:(NSString *)entityName
{
_objectClass = nil;
_entityName = [entityName copy];
}
- (void)setObjectClass:(Class)objetClass
{
_objectClass = objetClass;
_entityName = nil;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, and improved for case setting nil
to already nilled property.
I will rollout 1.1.1 tomorrow with added documentation from #69 |
@dimazen Thanks! |
Also change a few FEMMapping readonly properties to readwrite
Discussed here: #73