• 爱情文章
  • 亲情文章
  • 友情文章
  • 生活随笔
  • 校园文章
  • 经典文章
  • 人生哲理
  • 励志文章
  • 搞笑文章
  • 心情日记
  • 英语文章
  • 范文大全
  • 作文大全
  • 新闻阅读
  • 当前位置: 山茶花美文网 > 经典文章 > 正文

    c语言文件读取字符串 iOS从文本文件中读取内容到字符串里

    时间:2020-05-29来源:山茶花美文网 本文已影响 山茶花美文网手机站

    NSError *error;

    NSString *textFileContents = [NSString

    stringWithContentsOfFile:[[NSBundle mainBundle]

    pathForResource:@”myTextFile”

    ofType:@”txt”]

    encoding:NSUTF8StringEncoding

    error: & error];

    // If there are no results, something went wrong

    if (textFileContents == nil) {

    // an error occurred

    NSLog(@”Error reading text file. %@”, [error localizedFailureReason]);

    }

    NSArray *lines = [textFileContents componentsSeparatedByString:@” ”];

    NSLog(@”Number of lines in the file:%d”, [lines count] );

    • c语言文件读取字符串 iOS从文本文件中读取内容到字符串里 相关文章:
    • 爱情文章
    • 亲情文章
    • 友情文章
    • 随笔
    • 哲理
    • 励志
    • 范文大全