NSWrapper Plus Plain text files
NSWrapper Plus Plain text files
- Subject: NSWrapper Plus Plain text files
- From: Lincoln Green <email@hidden>
- Date: Fri, 14 Mar 2008 18:43:13 -0500
Hi, I am using loadFileWrapperRepresentation to implement a RTF/RTFD
reader. My code for RTF and RTFD support works, but I can't figure out
how to load in .txt files. the basic flow of the reader is, determine
the file type, set a NSAttributedString to a certain value depending
on the file type, and then load it into a textView. see the following
code.(rtfData is an NSAttributedString; textView is my TextView).
if ([type isEqualToString:@"Rich-Text With Attachments"]) {
rtfData = [[NSAttributedString
alloc]initWithRTFDFileWrapper:wrapper documentAttributes:nil];
}
else if ([type isEqualToString:@"Rich-Text"]) {
rtfData = [[NSAttributedString alloc]initWithRTF:[wrapper
regularFileContents] documentAttributes:nil];
}
else
{
//code for plain text
}
if (textView) {
[[textView
textStorage]replaceCharactersInRange:NSMakeRange(0, [[textView string]
length])withAttributedString:rtfData];
[rtfData release];
return YES;
}
Any suggestions?
Lincoln Green - Head of BinkWorks - the rather unskilled programmer -
etc
http://binkworks.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden