簡體   English   中英

NSDictionary Key存在,但返回nil

[英]NSDictionary Key exists but returns nil

我有一本包含對象但返回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

它一定不能喜歡引號,因為這會導致字符串相等性失敗:

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

'unicode :撇號)標記與'unicode :右單引號)不同,因此'=7+'不等於'=7+' (請注意最后一個字符)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM