0

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?

ck_
  • 3,719
  • 10
  • 49
  • 76

2 Answers2

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.");
}
ck_
  • 3,719
  • 10
  • 49
  • 76
0

Its just a characteristic of NSLog.

crackity_jones
  • 1,077
  • 2
  • 13
  • 16