Tuesday, June 5, 2007

Pulling in RTF Information in Objective-C

Okay,

So, a view pointed out that you can't pull in an RTF file because it's in binary.

I did some playing around and found a class derived from a string class called NSAttributedString.

If you want to pull in RTF information, this string does it. I successfully used this to pull in every line from an RTF in the application I posted to the demo server. I still haven't fixed it yet. But hey, RTF's are a possibility! :-)

To get the string data, I just created a new NSAttributedString and called the following init method.
  • [[NSAttributedString alloc] initWithPath:@"location.rtf" documentAttributes:nil];
Then I called the string property and returned a standard string.

The rest I solved using the way I demonstrated before.

Happy Coding :-)

1 comment: