代码之家  ›  专栏  ›  技术社区  ›  Ben Packard Ross Knipe

需要调查的NSString

  •  0
  • Ben Packard Ross Knipe  · 技术社区  · 15 年前

    我有一个需要分析的文本文件。这个文件包含一系列的短句,每一句都放在一个新行上。我通过使用componentsSeparatedByString构建一个行数组来完成此操作:@“\n”

    这在很大程度上是可行的。如果我记录@“这是字符串->%@<-那是字符串”我得到

    This is the string ->line1<-That was the string
    This is the string ->line2<-That was the string
    This is the string ->line3<-That was the string
    

    This is the string ->line1<-That was the string
    This is the string ->line2
    <-That was the string
    This is the string ->line3<-That was the string
    

    我看不出文件中的行有什么不同,所以试着将其复制并粘贴到word中。我看到,对于麻烦的部分,行在word中是双倍行距的。其他的部分,我没有问题。

    1 回复  |  直到 15 年前
        1
  •  4
  •   Carl Norum    15 年前

    看你的档案 hexdump 看看你有没有混合的线尾。你可能会有一些以 \n \r\n ,这可能会让人困惑。一般来说,确保你的输入是干净的总是一个好主意!除此之外,你需要扩展你的程序来处理任何使它混乱的情况。在调试器中拨弄字符串也会指向正确的方向。