AdvancedTableSearch/APLAppDelegate.m

/*
 Copyright (C) 2013-2014 Apple Inc. All Rights Reserved.
 See LICENSE.txt for this sample’s licensing information
 
 Abstract:
 The application delegate.
 */
 
#import "APLAppDelegate.h"
#import "APLViewController.h"
#import "APLProduct.h"
 
@implementation APLAppDelegate
 
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSArray *productArray = @[[APLProduct productWithType:ProductTypeDevice
                                                    name:@"iPhone"
                                                    year:[NSNumber numberWithInteger:2007]
                                                   price:[NSNumber numberWithDouble:599.00]],
                             [APLProduct productWithType:ProductTypeDevice
                                                    name:@"iPod"
                                                    year:[NSNumber numberWithInteger:2001]
                                                   price:[NSNumber numberWithDouble:399.00]],
                             [APLProduct productWithType:ProductTypeDevice
                                                    name:@"iPod touch"
                                                    year:[NSNumber numberWithInteger:2007]
                                                   price:[NSNumber numberWithDouble:210.00]],
                             [APLProduct productWithType:ProductTypeDevice
                                                    name:@"iPad"
                                                    year:[NSNumber numberWithInteger:2010]
                                                   price:[NSNumber numberWithDouble:499.00]],
                             [APLProduct productWithType:ProductTypeDevice
                                                    name:@"iPad mini"
                                                    year:[NSNumber numberWithInteger:2012]
                                                   price:[NSNumber numberWithDouble:659.00]],
                             [APLProduct productWithType:ProductTypeDesktop
                                                    name:@"iMac"
                                                    year:[NSNumber numberWithInteger:1997]
                                                   price:[NSNumber numberWithDouble:1299.00]],
                             [APLProduct productWithType:ProductTypeDesktop
                                                    name:@"Mac Pro"
                                                    year:[NSNumber numberWithInteger:2006]
                                                   price:[NSNumber numberWithDouble:2499.00]],
                             [APLProduct productWithType:ProductTypePortable
                                                    name:@"MacBook Air"
                                                    year:[NSNumber numberWithInteger:2008]
                                                   price:[NSNumber numberWithDouble:1799.00]],
                             [APLProduct productWithType:ProductTypePortable
                                                    name:@"MacBook Pro"
                                                    year:[NSNumber numberWithInteger:2006]
                                                   price:[NSNumber numberWithDouble:1499.00]]
                              ];
 
    UINavigationController *navigationController = (UINavigationController *)[self.window rootViewController];
    APLViewController *viewController = [navigationController.viewControllers objectAtIndex:0];
    viewController.products = productArray;
 
    return YES;
}
 
// required for state restoration
- (BOOL)application:(UIApplication *)application shouldSaveApplicationState:(NSCoder *)coder
{
    return YES;
}
 
// required for state restoration
- (BOOL)application:(UIApplication *)application shouldRestoreApplicationState:(NSCoder *)coder
{
    return YES;
}
 
@end