Created
June 2, 2015 17:43
-
-
Save vikdenic/bceea2d9ab9e2fa9cf2b to your computer and use it in GitHub Desktop.
populateWithRetiredHeroesIfEmpty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(void)populateWithRetiredHeroesIfEmpty | |
| { | |
| if (self.heroes.count < 2) { | |
| for (RetiredSuperhero *retiredSuperhero in self.retiredSuperheroes) { | |
| NSManagedObject *superhero = [NSEntityDescription insertNewObjectForEntityForName:@"Superhero" inManagedObjectContext:self.moc]; | |
| [superhero setValue:retiredSuperhero.name forKey:@"name"]; | |
| [superhero setValue:retiredSuperhero.textDescription forKey:@"textDescription"]; | |
| [superhero setValue:retiredSuperhero.urlString forKey:@"imageURL"]; | |
| [self.moc save:nil]; | |
| [self load]; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment