开发者

objective-c why does nslog show strings inbetween double quotation marks " "?

开发者 https://www.devze.com 2023-04-01 01:13 出处:网络
I am开发者_JAVA百科 loading a nsarray from a textfile: NSArray *noWords = [[NSArray alloc] initWithArray:

I am开发者_JAVA百科 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 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); 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消