views:

24

answers:

1

How do I read the contents of .doc file [not from resource file] into NSString in Objective-C?

I tried doing it in this way:

NSString *str = [NSString stringWithContentsOfFile:@"/User/home/Documents/config.doc"];
NSLog(@"Contents of file : %@",str);

OUTPUT: -+-% [encoded format]

output is in encoded format

How do I solve this problem? Is it not reading from file the proper contents or am I printing it wrong?

Thank You.

+1  A: 

The file you are using is probably binary, so when viewed as a string it will not work like you think. You would need some sort of library or decoding function that would parse and display a binary .doc file.

Though you may have more luck with a .docx file which I believe is an XML based format that Word can save.

Squeegy