我正在将字典(单词列表,而不是类)作为 NSStrings 加载到 NSSet 中。然后我反复向这个集合发送消息-containsObject:someNSString。但它总是返回 false。我写了一些代码来测试它:
NSLog(@"Random from dictionary: %@", [dictionary anyObject]);
NSString *test = [NSString stringWithFormat:@"BEMIRED"];
NSLog(@"To match this word: %@", test);
if ([dictionary containsObject:test])
NSLog(@"YES!");
在日志中,我得到以下信息:
Random from dictionary: BEMIRED
To match this word: BEMIRED
(我错过了“是的!”)
当我尝试使用 CFShow(dictionary) 时,我可以看到它实际上包含字符串和所有内容。一个例子:
0 : <CFString 0xc3bd810 [0x1386400]>{contents = "BEMIRED"}
3 : <CFString 0xdf96ef0 [0x1386400]>{contents = "SUBJECTIFIED"}
任何人都可以在这里帮助我吗?谢谢!