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
Post a Comment