NSLog - strange behavior

I found that the last word is shown 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"
)
+5
source share
2 answers

It appears that due to the special character -in the key, Ana-Luciait displays it in double quotes. Maybe this is because to show that the key is one word . If your key contains just alphabetslike "AnaLucia", then it will display it without quotes.

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

+7
source

- . NSArray *array = [NSArray arrayWithObjects:@"abc", @"123", @"$abc", @"a-b-c", @"a b c", nil];, , . , .

+7

All Articles