Reputation: 2489
i m trying to read a text file from my app bundle the contents of file are:
1234567890
but when i display the string after reading its like this:
{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320 {\fonttbl\f0\fswiss\fcharset0 Helvetica;} {\colortbl;\red255\green255\blue255;} \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
\f0\fs24 \cf0 1234567890 \ \ \ \ \ \ \ \ }
how can i get the exact string and not the garbage ? my code is this:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"pankaj" ofType:@"rtf"];
if (filePath) {
NSString *myText = [NSString stringWithContentsOfFile:filePath];
if (myText) {
NSLog(@"%@",myText);
}
}
good answers will ve appreciated
Upvotes: 0
Views: 684
Reputation: 75982
You are reading a rich-text formatted resource (rtf) as plain text. The string you get is the plain text representation of that rtf resource.
Why don't you add the file as a plain text file?
Upvotes: 1