Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone NSLog-奇怪的行为_Iphone_Objective C_Ios_Nslog - Fatal编程技术网

Iphone NSLog-奇怪的行为

Iphone NSLog-奇怪的行为,iphone,objective-c,ios,nslog,Iphone,Objective C,Ios,Nslog,我发现最后一个词是用双引号引出来的。但是为什么呢 NSDictionary *guide2 = [NSDictionary dictionaryWithObjectsAndKeys:kArr, @"Kate", aArr, @"Ana-Lucia", kArr, @"John", nil]; NSArray *array = [guide2 allKeys]; NSLog(@"%@", [array description]); 输出: ( John, Kate, "Ana-Lucia" )

我发现最后一个词是用双引号引出来的。但是为什么呢

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

(
John,
Kate,
"Ana-Lucia"
)

因为它不是严格意义上的字母数字和一个单词。Try
NSArray*array=[NSArray数组,其对象为:@“abc”、@“123”、@“$abc”、@“a-b-c”、@“a-b-c”、nil],您将看到只有前两个没有被引用。这只是编写描述代码的人的一个实现选择。

似乎由于Ana Lucia
键中的特殊字符
-
,它将其显示在双引号内。这可能是因为显示键是单个单词。如果您的键只包含
字母表
如“AnaLucia”,则它将显示它而不带引号

如果键包含除
字母表
以外的任何字符,即使它是
下划线(41;
空格
,也会以双引号显示