I have a setting in Root.plist with Key = 'latestNews' of type PSToggleSwitchSpecifier and DefaultValue as a boolean that is checked. If I understand that correctly, it should = YES when I pull it in to my code. I'm trying to check that value and set an int var to pass it to my php script. What is happening is that my boolean is either nil or NO and then my int var = 0. What am I doing wrong?
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
int latestFlag = ([[prefs objectForKey:@"latestNews"] isEqualToString:@"On"]) ? 1 : 0;
NSString *urlstr = [[NSString alloc] initWithFormat:@"http://www.mysite.com/folder/iphone-test.php?latest=%d", latestFlag];
NSURL *url = [[NSURL alloc] initWithString:urlstr];
//these are auto-released
NSString *ans = [NSString stringWithContentsOfURL:url];
NSArray *listItems = [ans componentsSeparatedByString:@","];
self.listData = listItems;
[urlstr release];
[url release];
UPDATED: The real problem is that I am failing to retrieve any settings values. I changed my boolean setting to a string, similar to the books example. So now my setting has a TrueValue = "On" and a FalseValue = "Off" with a DefaultValue = "On". I am now trying to retrieve this setting with the code above. It should = "On" given that is the DefaultValue, however my int is ending up = 0, suggesting that I am failing to read the setting at all.