Re: NSCharacterSet Parsing MS Word 97 files? <Newbie>
Re: NSCharacterSet Parsing MS Word 97 files? <Newbie>
- Subject: Re: NSCharacterSet Parsing MS Word 97 files? <Newbie>
- From: Vince Ackerman <email@hidden>
- Date: Wed, 6 Jul 2005 09:29:36 -0700
I was hoping to try a little experiment and see if NSAttributedString
would solve my Word Doc parsing problem... but I'm running into a
problem.
I Can't seem to get past a compile warning of
warning: 'NSAttributedString' may not respond to
'+initWithDocFormat:documentAttributes:'
and then a runtime error of
+[NSAttributedString initWithDocFormat:documentAttributes:]:
selector not recognized
I've checked the docs and this seems to be formatted right ( I think! )
This is the code snippet where the error occurs:
NSOpenPanel *panel = [NSOpenPanel openPanel];
NSDictionary * attributes = [NSDictionary dictionary];
if ([panel runModal] == NSOKButton)
{
NSString *fileName = [panel filename];
NSData *dataFile = [NSData dataWithContentsOfFile: fileName];
NSAttributedString * copyString = [NSAttributedString
initWithDocFormat: dataFile documentAttributes: attributes];
}
On Jul 4, 2005, at 10:08, j o a r wrote:
On 4 jul 2005, at 18.37, Vince Ackerman wrote:
I need to parse lengthy MS Word 97 documents. I have read the file
in as an NSString but need to filter out all the extraneous
characters except the actual text. I need to see all the standard
keyboard characters and (hopefully/eventually) parse out the
information into a Core Data database. I can achieve this using
Word to save the file as straight Text, but don't want the end
user to have to do this to each document every time. I was
hoping there was a way to do it programmatically without a lot of
work.
Is there a way to copy this string to another string with
NSCharacterSet or NSScanner? Or perhaps a better way to open and
read the file into a NSString without the MSWord encoding? I
don't fully understand what NSCharacterSet will filter, and I
don't want to alter the actual visible text in the file.
Any ideas would be greatly appreciated! Perhaps someone's got a
snippet of code so I don't have to re-invent this wheel?
I'm a total amateur, so go easy on me.... : )
This might be of a big help to you:
-[NSAttributedString initWithDocFormat:documentAttributes:]
<http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/ObjC_classic/Classes/NSAttributedString.html#//
apple_ref/doc/uid/20000167-BAJJHABH>
j o a r
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden