Application's First Launch XCode

Open AppDelegate.swift and modify this line:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
    return true
}
to
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {

 if (NSUserDefaults.standardUserDefaults().boolForKey("HasLaunchedOnce")){
  //app already launched 
  println("app already launched") 
 }else{
  NSUserDefaults.standardUserDefaults().setBool(true, forKey: "HasLaunchedOnce")
  NSUserDefaults.standardUserDefaults().synchronize()
  //This is the first launch ever
 
  println("this is the first launch ever")
 }

 return true
}
Application's First Launch XCode Application's First Launch XCode Reviewed by Edmond Legaspi on Thursday, July 03, 2014 Rating: 5

No comments:

Powered by Blogger.