判断ios程序第一次启动

来源:互联网 发布:互联网大会2017 知乎 编辑:程序博客网 时间:2024/06/05 04:37

方法有很多,但一列出一种

在didFinishLaunchingWithOptions里面写



if(![[NSUserDefaultsstandardUserDefaults] boolForKey:@"firstStart"]){

        [[NSUserDefaultsstandardUserDefaults] setBool:YESforKey:@"firstStart"];

        NSLog(@"第一次启动");

        UIAlertView *a = [[UIAlertViewalloc]initWithTitle:@"1"message:nildelegate:selfcancelButtonTitle:@"ok"otherButtonTitles:nil];

        [a show];

    }else{

        NSLog(@"不是第一次启动");

        UIAlertView *a = [[UIAlertViewalloc]initWithTitle:@"2"message:nildelegate:selfcancelButtonTitle:@"ok"otherButtonTitles:nil];

        [a show];

    }

0 0
原创粉丝点击