开发者

how to use text file [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_高级运维 Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜