手机
当前位置:查字典教程网 >编程开发 >IOS开发 >iOS从文本文件中读取内容到字符串里
iOS从文本文件中读取内容到字符串里
摘要:NSError*error;NSString*textFileContents=[NSStringstringWithContentsOfF...

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] );

【iOS从文本文件中读取内容到字符串里】相关文章:

ios开发过程中屏幕方向判断的问题

IOS生成与读取二维码名片

IOS检测指定路径的文件是否存在

IOS判断字符串是否有空格实例

iOS开发中最基本的位置功能实现示例

iOS中如何判断中英文混合的字符长度

详解iOS App中UITableView的创建与内容刷新

IOS开发之路--C语言数组和字符串

iOS自定义日历控件的简单实现过程

iOS实现消息推送及原理分析

精品推荐
分类导航