JBK
JBK

Reputation: 225

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.

Upvotes: 3

Views: 2475

Answers (1)

NSResponder
NSResponder

Reputation: 16861

Change that to:

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

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

Upvotes: 13

Related Questions