手机
当前位置:查字典教程网 >编程开发 >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读取txt文件出现中文乱码的解决方法

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

IOS开发中取消文本框输入时的小键盘

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

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

iOS获取cell中webview的内容尺寸

IOS中内存管理那些事

iOS系统Crash文件分析方法

iOS应用中存储用户设置的plist文件的创建与读写教程

精品推荐
分类导航