Adds monster type to editor.

Sets all entity attributes for monster to default to empty string instead of null.
Adds test for copyFromMonster.
Makes initWithMonster:andContext call copyFromMonster to ensure they use the same logic to clone the other monster.
This commit is contained in:
2020-09-12 03:30:37 -07:00
parent ee9994c2c8
commit 42ddfbd52f
4 changed files with 44 additions and 9 deletions

View File

@@ -73,6 +73,7 @@
self.name = [jsonRoot objectForKey:@"name"] ?: @"";
self.size = [jsonRoot objectForKey:@"size"] ?: @"";
self.type = [jsonRoot objectForKey:@"type"] ?: @"";
return self;
}
@@ -80,7 +81,7 @@
-(id)initWithMonster:(Monster* _Nonnull)monster {
self = [self initWithContext:monster.managedObjectContext];
self.name = monster.name;
[self copyFromMonster:monster];
return self;
}
@@ -334,6 +335,7 @@
-(void)copyFromMonster:(Monster*)monster {
self.name = monster.name;
self.size = monster.size;
self.type = monster.type;
}
@end