ios - Boolean for UIAlertController Objective-C -


a button triggers alert; alert "one-time", appearing once never appearing again after user hits "ok".

if boolean 0, alert triggered; if 1, alert not triggered. if user hits "ok", value of bool set 1.

which best way set one-time alert in objective-c?

i use nsuserdefaults store boolean flag you're talking about. so:

static nsstring * const alerthasbeenshownuserdefaultskey = @"alerthasbeenshownuserdefaultskey";  -(void)showalert {     nsuserdefaults *userdefaults = [nsuserdefaults standarduserdefaults];     if (![userdefaults boolforkey:alerthasbeenshownuserdefaultskey]) {         //show alert          [userdefaults setbool:yes forkey:alerthasbeenshownuserdefaultskey];     } } 

nsuserdefaults keep bool value across launches. value reset if user reinstalls app though.


Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -