在Objective-C中读取rtf文件

时间:2013-05-26 13:23:39

标签: ios objective-c xcode

我有一个rtf文件,有2行。我想在目标c中阅读它,每一行都应该在我的textView1和textView2对象中表示。这可能吗,你能帮帮我吗?

1 个答案:

答案 0 :(得分:2)

NSString* readme = [[NSBundle mainBundle] pathForResource:@"ReadMe" ofType:@"rtf"];
[textView1 readRTFDFromFile:readme];

修改

NSString *strFromFile = [NSString  stringWithContentsOfFile:@"readMe" encoding:NSASCIIStringEncoding error:null];
NSArray *array = [strFromFile componentsSeparatedByString:@"\n"];
[textView1 setText: [array objectAtIndex:0]];
[textView2 setText: [array objectAtIndex:1]];