Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective-C NSDictionary value comparison

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.
like image 493
JBK Avatar asked Dec 04 '25 00:12

JBK


1 Answers

Change that to:

if ([[game objectForKey:@"complete"] isEqualToString: @"T"]) 

What you were doing was comparing pointers to strings, not their contents.

like image 179
NSResponder Avatar answered Dec 05 '25 15:12

NSResponder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!