redbrain
redbrain

Reputation: 162

NSDictionary Key exists but returns nil

I have a dictionary which does contain an object but is returns nil.

// returns nil
(lldb) po [_contentRatings objectForKey:rating]
nil
// this is the rating string
(lldb) po rating
'=7+’
// using a literal string works
(lldb) po [_contentRatings objectForKey:@"'=7+'"]
5

It must be not liking the quotes since this fails string equality:

(lldb) po @"'=7+'"
'=7+'
(lldb) po rating
'=7+’
(lldb) p (BOOL)[@"'=7+'" isEqualToString:rating]
(BOOL) $10 = NO

Upvotes: 0

Views: 159

Answers (1)

michal.ciurus
michal.ciurus

Reputation: 3664

' (unicode: apostrophe) mark is different from (unicode: right single quotation mark) hence '=7+' isn't equal to '=7+’ (mind the last character)

Upvotes: 2

Related Questions