Search code examples
iphonesdkios4

Load rtf or text file into UITextView iphone sdk


Hi i was wondering how should i load rtf or text file into UITextView i use several codes but did't work ,

NSString* filePath = [[NSBundle mainBundle] pathForResource:@"filename" ofType:@"txt"];
myTextView.text = filePath;

thank you .


Solution

  • You may try with this:

    NSString *myText = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
    myTextView.text  = myText;