简体   繁体   中英

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

'unicode :撇号)标记与'unicode :右单引号)不同,因此'=7+'不等于'=7+' (请注意最后一个字符)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM