NSLog - Strange behavior

后端 未结 2 1920
一个人的身影
一个人的身影 2020-12-17 04:12

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

NSDictionary *guide2 = [NSDictionary dictionaryWithObjectsAndKeys:kArr, @\"Kate\", aArr, @\"Ana-Lu         


        
2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-17 04:28

    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.

提交回复
热议问题