ios - - (void)applicationWillEnterForeground: -
maybe assist me.
when app launched first time uialertcontroller message appears , asks user if need goto settings app. using following code.
dispatch_async(dispatch_get_main_queue(), ^{ [[uiapplication sharedapplication] openurl:[nsurl urlwithstring:@"prefs:root=wi-fi"]]; });
upon return app same uialertcontroller message appears, using code in viewdidload:
-(void)viewdidload { if (launched == no) { launched = yes; defaults = [nsuserdefaults standarduserdefaults]; [defaults setbool:launched forkey:@"boolkey"]; [defaults synchronize]; code uialertcontroller. } else if (launched == yes) { [self dosomething]; } }
it appears bool value not being saved when settings in info.plist application not run in background: set yes, if application not run in background: set no else statement executed. not because app suspended , when launched again need original message appear , not, app restored last state.
any suggestions appreciated.
jz
1.- saving nsuserdefaults not save info.plist. nsuserdefaults has own plist gets wiped out if remove application.
if want prevent launch same alertview:
nsuserdefaults *defaults = [nsuserdefaults standarduserdefaults]; if([defaults boolforkey:@"boolkey"]) { defaults = [nsuserdefaults standarduserdefaults]; [defaults setbool:yes forkey:@"boolkey"]; code uialertcontroller. } else { //whatever need if not first launch }
now next time hit viewdidload, since boolforkey:@"boolkey" has yes, won't hit code , alertview won't presented.
Comments
Post a Comment