ios - Settings Bundle Not Changing Results -


having difficulties settings bundle options , ability change settings within application.

my plist structured following way.

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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -