NSStrings "containing_underscore_characters" are wrapped in quotation marks when set in NSMutableDictionary? [duplicate]
I'm adding NSStrings to an NSMutableDictionary. Some strings contain an underscore, some do not:
NSMutableDictionary *testDict = [[NSMutableDictionary alloc] init];
[testDict setObject:@"_startWithUnderscore" forKey:@"firstKey"];
[testDict setObject:@"NoUnderscore" forKey:@"secondKey"];
[testDict setObject:@"underscores_in_middle" forKey:@"thirdKey"];
NSLog(@"%@", testDict);`
OUTPUT:
firstKey = "_startWithUnderscore";
//Note the added quotation marks!
secondKey = NoUnderscore;
//No quotation marks.
thirdKey = "underscores_in_middle";
//Also gets quote marks.
Uh, what's going on here? Where are the quotation marks coming from?
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.");
}
Its just a characteristic of NSLog.
精彩评论