NSStrings“包含下划线字符”在 NSMutableDictionary 中设置时用引号括起来?
我将 NSString 添加到 NSMutableDictionary 中。有些字符串包含下划线,有些则不包含:
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";
//注意添加的引号!
secondKey = NoUnderscore;
//没有引号。
thirdKey = "underscores_in_middle";
//也获取引号。
呃,这是怎么回事?引号从哪里来?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这只是NSLog的一个特性。
Its just a characteristic of NSLog.