I have file.txt data file in my project which is in resource folder.
Now i need to fetch the data from the file and load it into NSMutableArray.
how to approach to 开发者_开发技巧it.
First of all you need to read the file. And the you need to separate the string in components.
NSString *fileString = [NSString stringWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"test" ofType:@"txt"]
encoding:NSUTF8StringEncoding
error:nil];
NSMutableArray *stringsArray = [NSMutableArray arrayWithArray:[fileString componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]];
NSLog(@"Array:%@",[stringsArray description]);
Good luck.
精彩评论