Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在使用 Xcode 添加文本文件时遇到问题。我有读取它的编码设置,但我不知道将 .txt 文件放在哪里。我在 Product 文件夹下有 .txt,但它会给我一个不想要的输出。我用谷歌搜索并问过我的导师,但他不知道。请帮忙。
你得到什么不想要的输出?
然后将您的文本文件拖放到xcode上
NSString *textFilePath = [[NSBundle mainBundle] pathForResource: @"textfilename" ofType: @"txt"]; NSString *text = [NSString stringWithContentsOfFile:textFilePath usedEncoding:NSUTF8Encoding error:nil];