Objective-c 为什么 nslog 在双引号之间显示字符串""? [英] objective-c why does nslog show strings inbetween double quotation marks " "?
本文介绍了Objective-c 为什么 nslog 在双引号之间显示字符串""?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从文本文件加载一个 nsarray:
I am loading a nsarray from a textfile:
NSArray *noWords = [[NSArray alloc] initWithArray:
[[NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"untitled" ofType:@"txt"]
encoding:NSUTF8StringEncoding error:NULL] componentsSeparatedByString:@"\n"]];
Untitled.txt 包含:
Untitled.txt contains:
alfa
beta (geologi).
beta
jaha
javel
jam (geologi) en
jamen
jamen
jamen
jax. (geologi)jammen
det
var
æhæhæ
øhøh
på
tide
.(geologi),be;ta;
tiden
men
but
men
aha
beta
NSLog (@"noWords : %@", noWords);显示:
NSLog (@"noWords : %@", noWords); shows:
2011-08-29 16:16:44.288 scanner2[30177:207] noWords : (
alfa,
"beta (geologi).",
beta,
jaha,
javel,
"jam (geologi) en",
jamen,
jamen,
jamen,
"jax. (geologi)jammen",
det,
var,
"\U00e6h\U00e6h\U00e6",
"\U00f8h\U00f8h",
"p\U00e5",
tide,
".(geologi),be;ta;",
tiden,
men,
but,
men,
aha,
beta
推荐答案
当字符串中有空格或其他特殊字符时,它会这样做.请注意,这正是 NSLog()
所做的.当您执行 [NSString stringWithFormat:...]
时,这不会发生.
It does that when there are spaces or other special characters in the string. Note that this is just what NSLog()
does. When you do [NSString stringWithFormat:...]
this doesn't happen.
这篇关于Objective-c 为什么 nslog 在双引号之间显示字符串""?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文