开发者

objective-c: NSMutableString must start with a \n character

Okay, this is weird as hell, and I just want a sanity check 开发者_JAVA技巧to prove that I am not hallucinating from the lack of sleep.

NSMutableString *s = [NSMutableString stringWithFormat:@""];
for(int i=0; i<9; i++){
    for (int j=0; j<9; j++){
        [s appendString:[NSString stringWithFormat:@"%d ", arr[i][j]]];
    }
    [s appendString:@"\n"];
}
NSLog(s);

The Log window displays all contents in arr except the first row. If I change the first line to

NSMutableString *s = [NSMutableString stringWithFormat:@"\n"];

it prints correctly.

Any reasonable explanations?


From my comment: Is it possible that the first element of the array is being printed, but it's coming right after the timestamp in the log and you're not noticing it?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜