Skip to content

Commit

Permalink
The resetView method was added into the CarDetailViewController imple…
Browse files Browse the repository at this point in the history
…mentation. And the Serie MVC was improved to work with the notification system
  • Loading branch information
karmatr0n committed Oct 15, 2013
1 parent 9dcded7 commit 1bdcfba
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
Binary file not shown.
18 changes: 17 additions & 1 deletion CarSideBySide/CarDetailViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @"";
}

Expand Down Expand Up @@ -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
13 changes: 11 additions & 2 deletions CarSideBySide/CarListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 4 additions & 0 deletions CarSideBySide/Serie.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand Down
6 changes: 6 additions & 0 deletions CarSideBySide/SerieListViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "AppDelegate.h"
#import "Serie.h"
#import "CarListViewController.h"
#import "CarDetailViewController.h"
#import "CoreDataSeed.h"
#import "NetworkReachability.h"

Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 1bdcfba

Please sign in to comment.