iOS 判斷App是否第一次啓動

  1. #define LAST_RUN_VERSION_KEY @"last_run_version_of_application"    

  2. - (BOOL) isFirstLoad{    

  3. NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary]    

  4. objectForKey:@"CFBundleShortVersionString"];     

  5.     

  6. NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];    

  7.     

  8. NSString *lastRunVersion = [defaults objectForKey:LAST_RUN_VERSION_KEY];    

  9.     

  10. if (!lastRunVersion) {    

  11. [defaults setObject:currentVersion forKey:LAST_RUN_VERSION_KEY];    

  12. return YES;    

  13. }    

  14. else if (![lastRunVersion isEqualToString:currentVersion]) {    

  15. [defaults setObject:currentVersion forKey:LAST_RUN_VERSION_KEY];    

  16. return YES;    

  17. }    

  18. return NO;    

  19. }    


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章