Objective-C NSDictionary value comparison
-
06-07-2019 - |
Question
I am returning a string of either T or F from an NSDictionary key value pair. I'm trying to find out if it is the T or the F, but it never works like I would expect it to. I'm sure there is a very basic solution for this issue.
if ([game objectForKey:@"complete"] == @"T") never evaluates to true.
Solution
Change that to:
if ([[game objectForKey:@"complete"] isEqualToString: @"T"])
What you were doing was comparing pointers to strings, not their contents.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow