ios - Settings Bundle Not Changing Results -
having difficulties settings bundle options , ability change settings within application.
my plist structured following way.
in viewdidload method have following:
lbl = [[uilabel alloc] initwithframe:cgrectmake(0, 0, 320, 80)]; lbl.backgroundcolor = [uicolor clearcolor]; lbl.textcolor = [uicolor whitecolor]; lbl.text = @"hello world"; lbl.textalignment = nstextalignmentcenter; [self.view addsubview:lbl]; [lbl release]; bool changebg = (bool)[[nsuserdefaults standarduserdefaults] valueforkey:@"cellswitched"]; if (changebg) { lbl.textcolor = [uicolor redcolor]; } else { lbl.textcolor = [uicolor blackcolor]; }
the label changing black, never red. have tried rebooting device / reinstalling app. seems switch has no effect.
the code should be:
bool changebg = [[nsuserdefaults standarduserdefaults] boolforkey:@"cellswitched"];
you misusing valueforkey , incorrectly casting result.
Comments
Post a Comment