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