ios - Remember state of uiswitch -


i have uiswitch in app. if on writes in core data "yes" if off writes "no"

this working now, if leave view off again.

-(ibaction)theswitch {     if (switchbutton.on) {         [self.detailitem setvalue:@(yes) forkey:@"done"];      } else {         [self.detailitem setvalue:@(no) forkey:@"done"];     } } 

on viewdidload saved value detail item

theswitch.on = [[self.detailitem valueforkey:@"done"] boolvalue]; 

and saving data item (thanks dan shelly)

nserror *saveerror; [self.detailitem.managedobjectcontext save:&saveerror]; // check if saveerror nil error checking 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -