| | 41 | } |
| | 42 | |
| | 43 | + (void)upgradeV1ShowsFromContext:(NSManagedObjectContext *)oldMoc toContext:(NSManagedObjectContext *)newMoc |
| | 44 | { |
| | 45 | NSArray *oldShows = doFetchRequest(SapphireTVShowName, oldMoc, nil); |
| | 46 | NSEnumerator *showEnum = [oldShows objectEnumerator]; |
| | 47 | NSManagedObject *oldShow; |
| | 48 | while((oldShow = [showEnum nextObject]) != nil) |
| | 49 | { |
| | 50 | SapphireTVShow *newShow = [NSEntityDescription insertNewObjectForEntityForName:SapphireTVShowName inManagedObjectContext:newMoc]; |
| | 51 | newShow.name = [oldShow valueForKey:@"name"]; |
| | 52 | newShow.showDescription = [oldShow valueForKey:@"showDescription"]; |
| | 53 | newShow.showID = [oldShow valueForKey:@"showID"]; |
| | 54 | newShow.showPath = [oldShow valueForKey:@"showPath"]; |
| | 55 | |
| | 56 | NSEnumerator *translationEnum = [[oldShow valueForKey:@"translations"] objectEnumerator]; |
| | 57 | NSManagedObject *translation; |
| | 58 | while((translation = [translationEnum nextObject]) != nil) |
| | 59 | { |
| | 60 | [SapphireTVTranslation upgradeV1TVTranslation:translation toShow:newShow]; |
| | 61 | } |
| | 62 | |
| | 63 | NSEnumerator *seasonEnum = [[oldShow valueForKey:@"seasons"] objectEnumerator]; |
| | 64 | NSManagedObject *season; |
| | 65 | while((season = [seasonEnum nextObject]) != nil) |
| | 66 | { |
| | 67 | [SapphireSeason upgradeV1Season:season toShow:newShow]; |
| | 68 | } |
| | 69 | } |