suse
suse

Reputation: 10563

How to read the contents of .doc file into string in XCode?

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.

Upvotes: 1

Views: 1711

Answers (1)

Alex Wayne
Alex Wayne

Reputation: 187134

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.

Upvotes: 2

Related Questions