我正在将NSStrings添加到NSMutableDictionary中。有些字符串包含下划线,有些则不包含:
NSMutableDictionary *testDict = [[NSMutableDictionary alloc] init];
[testDict setObject:@"_startWithUnderscore" forKey:@"firstKey"];
[testDict setObject:@"NoUnderscore" forKey:@"secondKey"];
[testDict setObject:@"underscores_in_middle" forKey:@"thirdKey"];
NSLog(@"%@", testDict);`
输出:
firstKey = "_startWithUnderscore";
//注意添加的引号!
secondKey = NoUnderscore;
//没有引号。
thirdKey = "underscores_in_middle";
//也会获得引号。
答案 0 :(得分:1)
if ([[testDict objectForKey:@"firstKey"] substringWithRange:NSMakeRange(0, 1)] isEqualToString:@"_"])
{
NSLog(@"I guess the quotes are just things that NSLog prints, definitely not actually in the NSString.");
}
答案 1 :(得分:0)
它只是NSLog的一个特征。