赞
踩
作者:Loving_iOS
转载请标明出处:http://blog.csdn.net/loving_ios/article/details/50435840
方法一、在didFinishLaunchingWithOptions方法中加入如下代码:
- if(![[NSUserDefaults standardUserDefaults] boolForKey:@"firstLaunch"]){
- [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"firstLaunch"];
- //第一次启动
- }else{
- //不是第一次启动了
- }
- #define LAST_RUN_VERSION_KEY @"last_run_version_of_application"
- - (BOOL) isFirstLoad{
- NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary]
- objectForKey:@"CFBundleShortVersionString"];
-
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-
- NSString *lastRunVersion = [defaults objectForKey:LAST_RUN_VERSION_KEY];
-
- if (!lastRunVersion) {
- [defaults setObject:currentVersion forKey:LAST_RUN_VERSION_KEY];
- return YES;
- }
- else if (![lastRunVersion isEqualToString:currentVersion]) {
- [defaults setObject:currentVersion forKey:LAST_RUN_VERSION_KEY];
- return YES;
- }
- return NO;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。