Determine the first time iOS app starts someone else's hey

Source: Internet
Author: User

The popular solution is to use [Nsuserdefaults standarduserdefaults a key in most places, if it doesn't exist, which means that this is the Application launcher, otherwise it's not the first time

In APPDELEGATE.M, locate the "Application:didfinishlaunchingwithoptions:" Method and add the following code:

if (![[NSUserDefaults standardUserDefaults] boolForKey:@ "everLaunched" ]) {     [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@ "everLaunched" ];     [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@ "firstLaunch" ]; } else {     [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@ "firstLaunch" ]; } 总的解决办法是 2 个key: @”everLaunched”判断用户以前是否登录,   @”firstLaunch” 用来开发者在程序的其他部分判断. 在第一次启动的时候 key @”everLaunched” 不会被赋址的, 并且设置为YES. @”firstLaunch” 被设置为 YES. 在程序的其他部分用以下代码判断: if ([[NSUserDefaults standardUserDefaults] boolForKey:@ "firstLaunch" ]) {     // 这里判断是否第一次 UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@ "第一次"    message:@ "进入App"                                                                delegate:self cancelButtonTitle:@ "我知道了" otherButtonTitles:nil]; [alert show]; [alert release]; } The first piece of code runs key @ "Firstlaunch" will be set to NO

Determine the first time iOS app starts someone else's hey

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.