I’m having a problem getting one of my conditional statements to display data correctly. Here is the code I’m working with:
NSUserDefaults *pickerDefaults = [NSUserDefaults standardUserDefaults];
NSString *myString = [pickerDefaults stringForKey:@"userpicker"];
NSString *string = @"Name1";
NSLog(@"%@",myString); //This prints out Name1
NSLog(@"%@",string); //This also prints out Name1
if (myString == string) {
[pickerArray addObject:@"Name Other"];
}
else {
return;
}
I can’t get this if statement to add that object to the UIPicker eventhough both strings are equal to each other. However, if I change it to not equal to != then it display’s the object in the UIPickerView. I don’t understand what I’m doing wrong. Any help would be great. Thanks.
To compare string objects, don’t use their pointer values, but compare using