diff --git a/CarSideBySide.xcworkspace/xcuserdata/alex.xcuserdatad/UserInterfaceState.xcuserstate b/CarSideBySide.xcworkspace/xcuserdata/alex.xcuserdatad/UserInterfaceState.xcuserstate index f962d61..1fa4d9c 100644 Binary files a/CarSideBySide.xcworkspace/xcuserdata/alex.xcuserdatad/UserInterfaceState.xcuserstate and b/CarSideBySide.xcworkspace/xcuserdata/alex.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/CarSideBySide/CarDetailViewController.m b/CarSideBySide/CarDetailViewController.m index 82109b3..c5540a8 100644 --- a/CarSideBySide/CarDetailViewController.m +++ b/CarSideBySide/CarDetailViewController.m @@ -31,7 +31,11 @@ -(void)setCar:(Car *)newCar if (_car != newCar) { _car = newCar; } - [self configureView]; + if (_car != nil) { + [self configureView]; + } else { + [self resetView]; + } self.prevSegueIdentifier = @""; } @@ -200,4 +204,16 @@ - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sende } } +- (void)resetView +{ + self.navBarItem.title = @"Tablas comparativas"; + NSString *dummyImagePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"../CarSideBySide.app/DefaultCarDetailViewController.png"]; + NSData *data = [NSData dataWithContentsOfFile:dummyImagePath]; + carImageView.image = [UIImage imageWithData:data]; + modelLabel.text = @"BMW México"; + highlighsTextView.text = @"Selecciona una serie y un modelo..."; + highlighsTextView.font = [UIFont systemFontOfSize:32.0f]; + [self.toolbar setHidden:YES]; +} + @end diff --git a/CarSideBySide/CarListViewController.m b/CarSideBySide/CarListViewController.m index 884b516..3125a71 100644 --- a/CarSideBySide/CarListViewController.m +++ b/CarSideBySide/CarListViewController.m @@ -54,8 +54,17 @@ - (void)viewDidLoad for (Line *line in [self.serie.lines sortedArrayUsingDescriptors:sortDescriptors]) { - NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: line, @"line", [line.cars sortedArrayUsingDescriptors:sortLines], @"cars", nil]; - [data addObject:dict]; + if ([line.enabled boolValue] == YES) { + NSMutableArray *cars = [NSMutableArray array]; + for ( Car *car in [line.cars sortedArrayUsingDescriptors:sortLines]) { + if ([car.enabled boolValue] == YES) { + [cars addObject: car]; + } + } + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: line, @"line", [cars copy], @"cars", nil]; + [data addObject:dict]; + + } } [self.filteredData removeAllObjects]; [self.tableView reloadData]; diff --git a/CarSideBySide/Serie.m b/CarSideBySide/Serie.m index 2ace5c9..396e48b 100644 --- a/CarSideBySide/Serie.m +++ b/CarSideBySide/Serie.m @@ -32,6 +32,10 @@ + (NSArray *)findAllEnabled { [request setEntity:entity]; NSSortDescriptor *sortDescriptors = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]; [request setSortDescriptors: [NSArray arrayWithObject:sortDescriptors]]; + + NSPredicate *predicate = [NSPredicate predicateWithFormat:@"enabled == 1"]; + [request setPredicate:predicate]; + NSError *error; NSFetchedResultsController *fetchResults = [[NSFetchedResultsController alloc] initWithFetchRequest:request managedObjectContext:(id)[appDelegate managedObjectContext] sectionNameKeyPath:nil cacheName:@"CarCatalogStream"]; diff --git a/CarSideBySide/SerieListViewController.m b/CarSideBySide/SerieListViewController.m index e6ec5c8..fc4b4a3 100644 --- a/CarSideBySide/SerieListViewController.m +++ b/CarSideBySide/SerieListViewController.m @@ -10,6 +10,7 @@ #import "AppDelegate.h" #import "Serie.h" #import "CarListViewController.h" +#import "CarDetailViewController.h" #import "CoreDataSeed.h" #import "NetworkReachability.h" @@ -59,6 +60,11 @@ - (IBAction)reload:(id)sender [appDelegate updateRemoteDeviceInfo:userInfo]; [UIApplication sharedApplication].applicationIconBadgeNumber = 0; }); + + CarDetailViewController *carDetailViewController = [self.splitViewController.viewControllers lastObject]; + + [carDetailViewController selectedCar:nil]; + [self.navigationController popToRootViewControllerAnimated:YES]; } else { HUD.labelText = [networkReachability currentReachabilityString]; [HUD hide:YES afterDelay:2];