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.