5

I found that last word showed with double quotes. But why?

NSDictionary *guide2 = [NSDictionary dictionaryWithObjectsAndKeys:kArr, @"Kate", aArr, @"Ana-Lucia", kArr, @"John",  nil];
NSArray *array = [guide2 allKeys];
NSLog(@"%@", [array description]);

output:

(
John,
Kate,
"Ana-Lucia"
)
EmptyStack
  • 51,274
  • 23
  • 147
  • 178
Voloda2
  • 12,359
  • 18
  • 80
  • 130

2 Answers2

7

Because it's not strictly alphanumeric and one word only. Try NSArray *array = [NSArray arrayWithObjects:@"abc", @"123", @"$abc", @"a-b-c", @"a b c", nil];, you'll see only the first two are not quoted. It's just an implementation choice from the guy who wrote the description code.

Jano
  • 62,815
  • 21
  • 164
  • 192
7

It seems that because of the special character - in the key Ana-Lucia, it displays it within double-quotes. May be this is because to show that the key is a single word. If your key contains only alphabets like "AnaLucia", then it will display it without quotes.

The key is displayed in double-quotes if it contains any characters other than alphabets, even if it is an underscore(_) or space.

EmptyStack
  • 51,274
  • 23
  • 147
  • 178