我有一个.txt
文件,其中存在一些数据,当我将其存储在数组中时,我得到了50000个字。我想根据用户输入从文本文件中搜索数据并将其显示在UITableview
单元格上,这怎么可能?有谁能够帮助我?
这是我的代码,用于从.txt
文件中读取数据viewDidLoad
:
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"myList" ofType:@"txt"];
NSError *error;
NSString *fileContents = [NSString stringWithContentsOfFile:filepath encoding:NSUTF8StringEncoding error:&error];
if (error)
NSLog(@"Error reading file: %@", error.localizedDescription);
// maybe for debugging...
NSLog(@"contents: %@", fileContents);
NSArray *listArray = [fileContents componentsSeparatedByString:@"\n"];
NSLog(@"items = %d", [listArray count]);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句