• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
readFromURL:url options: not working for me
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

readFromURL:url options: not working for me


  • Subject: readFromURL:url options: not working for me
  • From: David Rice <email@hidden>
  • Date: Mon, 12 Jul 2004 12:24:45 -0400

I am trying to open an RTFD file in such a way as to display the document's bg color.

Files that I save cannot be opened but the code works with Revert.
i.e. When I create a file, save it , change the open file and choose Revert, the following code executes and the document reverts to the saved version.
However, when this code is run upon Opening a file, the "readFromURL:url" does not work.

Can someone shed some light on this. I just don't know what I'm doing wrong.

- (BOOL)readFromFile:(NSString *)fileName ofType:(NSString *)docType
{
NSMutableDictionary *options = [NSMutableDictionary dictionary];
NSDictionary *docAttrs;
text = [textView textStorage];
NSLayoutManager *layoutManager = [textView layoutManager];
NSURL *url = [NSURL fileURLWithPath:fileName];
id val;
BOOL success = NO;
[options setObject:NSRTFDTextDocumentType forKey:@"DocumentType"];
[[text mutableString] setString:@""]; // Empty the document
[layoutManager retain]; // Temporarily remove layout mgr so it doesn't work while loading
[text removeLayoutManager:layoutManager];
[text beginEditing]; // Bracket with begin/end editing for efficiency
success = [text readFromURL:url options:options documentAttributes:&docAttrs]; // Read!
[text endEditing];
[text addLayoutManager:layoutManager]; // Hook layout manager back up
[layoutManager release];
if (!success) return NO;
if ((val = [docAttrs objectForKey:@"BackgroundColor"])) [textView setBackgroundColor:val];
return YES;
}

Thanks,
David
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: readFromURL:url options: not working for me
      • From: "Louis C. Sacha" <email@hidden>
  • Prev by Date: Re: AppleScript create command
  • Next by Date: Re: How to use the .strings files from the code?
  • Previous by thread: Re: How to use the .strings files from the code?
  • Next by thread: Re: readFromURL:url options: not working for me
  • Index(es):
    • Date
    • Thread