iOS learning (determine the version number, determine whether the user is the first time landing effect)

Source: Internet
Author: User

Determine the version number

1. Get a status : Whether you have entered the main interface

Get to the current version

nsstring *key = (nsstring *)kcfbundleversionkey;

nsstring *version = [nsbundlemainbundle]. infodictionary [Key];

Get to Previous version

nsstring *lastversion = [[nsuserdefaultsstandarduserdefaults]  valueforkey:@ "1"];

2. If you have not entered the main interface , go to the boot page

If the two version number is the same , enter the main interface, otherwise go to the boot page

if (! [Lastversion isequaltostring: Version]) {

viewcontroller *VC = [[viewcontrolleralloc]init];

[VCsetcallback: ^{

[selfstartApp];

[[nsuserdefaultsstandarduserdefaults]setValue: Versionforkey:@ "1"] ; (used a block usage, previously written)

[[nsuserdefaultsstandarduserdefaults]synchronize];

}];

Self. window. Rootviewcontroller = VC;

}

3. If you have entered the main interface, go directly to the main interface

Else

{

jump statements into the main interface

}


Determine if the user is the first time landing effect


1. Get a status, whether you have entered the main interface

BOOL b = [[[nsuserdefaultsstandarduserdefaults]Valueforkey : @ "FirstRun" ]boolvalue];

2. If you have not entered the main interface then go to the Guide page

if (!B) {

loginviewcontroller *j = [[loginviewcontrolleralloc]init ];

[Jsetcallback: ^{

[[nsuserdefaultsstandarduserdefaults]setValue:@YES forkey:@ "FirstRun"];

[[nsuserdefaultsstandarduserdefaults]synchronize];

}];

uinavigationcontroller *nav = [[uinavigationcontrolleralloc]INI Twithrootviewcontroller: j];

self. window . Rootviewcontroller = nav;


}

3. Otherwise enter the main interface

Else {

mytabbarviewcontroller *mv = [[mytabbarviewcontrolleralloc]init< /c5>];

self. window . Rootviewcontroller = mv;


}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

iOS learning (determine the version number, determine whether the user is the first time landing effect)

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.