how to use text file [closed]
how to use text file through code for iphone
NSString *filePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:yourFileName];
or
NSString *filePath = [[NSBundle mainBundle] pathForResource:yourFileName ofType:@"text"];
NSString *myText = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
Hope this helps
Hope it helps you...
Read content from File:
NSString *fileContents = [NSString stringWithContentsOfFile:@"myfile.txt"];
Write content from file:
[fileContents writeToFile:@"myfile.text" atomically:YES];
reading a file:
NSString *fileContent=[NSString stringWithContentsOfFile:textfilePath encoding:NSASCIIStringEncoding error:NULL];
And use the fileContent.
精彩评论