Skip to content

Instantly share code, notes, and snippets.

@vikdenic
Created June 2, 2015 17:43
Show Gist options
  • Select an option

  • Save vikdenic/bceea2d9ab9e2fa9cf2b to your computer and use it in GitHub Desktop.

Select an option

Save vikdenic/bceea2d9ab9e2fa9cf2b to your computer and use it in GitHub Desktop.
populateWithRetiredHeroesIfEmpty
-(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