CatNiP prefinal
Sähköinen nuottikirja, HY-TKTKL-OHTUPROJ KESÄ11
/Users/awniemel/Notepad-SVN/svn/trunk/CatNiP/CatNiP/CatNiPAppDelegate.m
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #import "CatNiPAppDelegate.h"
00009 
00010 #import "CatNiPViewController.h"
00011 #import "LocalDataHandler.h"
00012 
00013 @implementation CatNiPAppDelegate
00014 
00015 
00016 @synthesize window=_window;
00017 
00018 @synthesize viewController=_viewController;
00019 
00020 - (void)installUncaughtExceptionHandler
00021 {
00022         InstallUncaughtExceptionHandler();
00023 }
00024 
00025 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
00026 {
00027     self.window.rootViewController = self.viewController;
00028     [self.window makeKeyAndVisible];
00029 
00031     _viewController.localDelegateAndDataSource.allLocalScores = [LocalDataHandler loadLocalScoresFromDefaultFile];
00032 
00034     _viewController.playlistsDelegateAndDataSource.playlists = [LocalDataHandler loadPlaylistsFromDefaultFile:_viewController.localDelegateAndDataSource.allLocalScores];
00035     
00036     // library type is set to local when application starts 
00037     [_viewController.localDelegateAndDataSource changeLibraryTypeToLocal];
00038         [self performSelector:@selector(installUncaughtExceptionHandler) withObject:nil afterDelay:0];
00039 
00040     
00041     return YES;
00042 }
00043 
00044 - (void)applicationWillResignActive:(UIApplication *)application
00045 {
00046     /*
00047      Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
00048      Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
00049      */
00050 }
00051 
00052 - (void)applicationDidEnterBackground:(UIApplication *)application
00053 {
00054     
00055     [LocalDataHandler saveScoresToDefaultFile:_viewController.localDelegateAndDataSource.allLocalScores];
00056     [LocalDataHandler savePlaylistsToDefaultFile:_viewController.playlistsDelegateAndDataSource.playlists];
00057   
00058     /*
00059      Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
00060      If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
00061      */
00062 }
00063 
00064 - (void)applicationWillEnterForeground:(UIApplication *)application
00065 {
00066     /*
00067      Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
00068      */
00069 }
00070 
00071 - (void)applicationDidBecomeActive:(UIApplication *)application
00072 {
00073     /*
00074      Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
00075      */
00076 }
00077 
00078 - (void)applicationWillTerminate:(UIApplication *)application
00079 {
00080     [LocalDataHandler saveScoresToDefaultFile:_viewController.localDelegateAndDataSource.allLocalScores];
00081     [LocalDataHandler savePlaylistsToDefaultFile:_viewController.playlistsDelegateAndDataSource.playlists];
00082      
00083     /*
00084      Called when the application is about to terminate.
00085      Save data if appropriate.
00086      See also applicationDidEnterBackground:.
00087      */
00088 }
00089 
00090 - (void)dealloc
00091 {
00092     [_window release];
00093     [_viewController release];
00094     [super dealloc];
00095 }
00096 
00097 @end
 All Classes Files Functions Variables Enumerations Enumerator Properties Defines