1 //2 3 //APPDELEGATE.M4 5 //appdelegate6 7 //8 9 //Created by Apple on 13-7-10.Ten One //Copyright (c) 2013 itcast. All rights reserved. A - // - the - - #import "AppDelegate.h" - + - + #import "ViewController.h" A at - - @implementationappdelegate - - - in- (void) Dealloc - to { + - [_window release]; the * [_viewcontroller release]; $ Panax Notoginseng [Super Dealloc]; - the } + A the + #pragmaMark app is loaded (by default, it only prints 1 times) - $ //launchoptions: Contains some information about app launches (such as opening apps by clicking Notifications) $ --(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) Launchoptions - the { - WuyiSelf.window =[[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease]; the - //Override point for customization after application launch. Wu -Self.viewcontroller = [[[Viewcontroller alloc] Initwithnibname:@"Viewcontroller"Bundle:nil] autorelease]; About $Self.window.rootViewController =Self.viewcontroller; - - [Self.window makekeyandvisible]; - A + theNSLog (@"Didfinishlaunchingwithoptions--app Loading Complete"); - $ returnYES; the the } the the - in #pragmaMark loses focus. the the //program enters inactive state About the- (void) Applicationwillresignactive: (UIApplication *) Application the the { + -NSLog (@"applicationwillresignactive-Not activated"); the Bayi } the the - - #pragmaMark goes backstage. the the //typically save data in this method the the- (void) Applicationdidenterbackground: (UIApplication *) Application - the { the theNSLog (@"applicationdidenterbackground-into the background");94 the the the //Keep your program running in the background98 About[Application beginbackgroundtaskwithexpirationhandler:^{ - 101NSLog (@"background run time has expired");102 103 }];104 the 106 107 //Cancel All Notifications108 109 [Application cancelalllocalnotifications]; the 111 the 113Uilocalnotification *note =[[[ Uilocalnotification alloc] init] autorelease]; the the //set the text of a notification the 117Note.alertbody =@"hurry back, brother! ";118 119 //set the time interval for notifications to occur - 121Note.repeatinterval =Nsminutecalendarunit;122 123 //to set a sound for notifications to appear124 the //note.soundname = @ "Xxx.wav";126 127 //set the time the notification first appears - 129Note.firedate = [NSDate datewithtimeintervalsincenow:4]; the 131 the 133 //Publish Notifications134 135 //[Application presentlocalnotificationnow:<# (uilocalnotification *) #>];136 137 [Application schedulelocalnotification:note];138 139 } $ 141 142 143 #pragmaMark enters the front desk144 145- (void) Applicationwillenterforeground: (UIApplication *) Application146 147 {148 149NSLog (@"applicationwillenterforeground-Enter the front desk"); Max 151 } the 153 154 155 #pragmaMark when the app is activated (with the focus and can interact with the user)156 157 //At this time the program is in: Running State158 159- (void) Applicationdidbecomeactive: (UIApplication *) Application the 161 {162 163NSLog (@"applicationdidbecomeactive-is running");164 165 }166 167 168 169 #pragmaMark when the app receives a memory warning the 171 //It is common to reclaim unnecessary memory here172 173 //1. Easily create back-up objects174 175 //2. Objects that occupy a large memory176 177- (void) Applicationdidreceivememorywarning: (UIApplication *) Application {178 179NSLog (@"applicationdidreceivememorywarning-Memory Warning"); the 181 }182 183 184 185 186 187 #pragmaMark is called when the program is in the running state and the program is closed.188 189- (void) Applicationwillterminate: (UIApplication *) Application the 191 {192 193NSLog (@"applicationwillterminate--program is closed");194 195 }196 197 @end198 199
iOS uiapplication detailed (2)