将 .txt 文件分成单独的字符串
我已经知道如何上传文件并将其内容放入字符串中:
NSString *fileContents = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"WellBalanced Recipes" ofType:@"txt"]
encoding:NSUTF8StringEncoding
error:NULL];
但是,我想将此文本文档解析为单独的字符串。例如,如果我在同一个文档中有不同的食谱,我想以某种方式分离每个食谱。
I already know how to upload a file and place its contents into a string with:
NSString *fileContents = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"WellBalanced Recipes" ofType:@"txt"]
encoding:NSUTF8StringEncoding
error:NULL];
However, I would like to parse this text document into separate strings. For example, if I had different recipes in the same document, I would like to somehow separate each recipe.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
- (NSArray *)componentsSeparatedByString:(NSString *)separator
Use
- (NSArray *)componentsSeparatedByString:(NSString *)separator