• 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
Getting RTFD data into an NSData object.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting RTFD data into an NSData object.


  • Subject: Getting RTFD data into an NSData object.
  • From: Mark Stockwell <email@hidden>
  • Date: Sun, 4 Jul 2004 18:21:29 -0500

I'm trying to implement a master-detail interface with the detail
coming from a big ol' NSTextView. I had it working with simple strings,
but I want it to work with embedded pictures, formatting and such like
that. So whenever I change items: I get an NSTextStorage object from
the NSTextView, grab an NSData object from the NSTextStorage object,
and I save that with my item for later like this:

NSTextStorage* textStorage=[detailTextView textStorage];
NSRange range = NSMakeRange(0, [textStorage length]);
NSData *data = [detailTextView RTFDFromRange:range];
if (data != nil) [[item properties] setObject: data forKey: @"detail"];

That part seems to work. What I can't figure out how to do, though, is
initialize my item the first time when I have no NSTextView to grab an
NSTextStorage item from. I've tried stuff like:

NSString *s = @"Detail";
NSData *data = [[NSData alloc] initWithBytes:[s cString] length:[s
length]];
NSArray *values = [NSArray arrayWithObjects: [NSNumber
numberWithInt:0],[NSDate date], data, @"item", nil];


but when I try to access that object with this code:

NSData* data = [[item properties] objectForKey: @"detail"];
NSTextStorage* textStorage=[detailTextView textStorage];
NSRange range = NSMakeRange(0, [textStorage length]);
[detailTextView replaceCharactersInRange:range withRTFD:data];

I get this error message:

Unable to read RTFD from data:0x3ae7b0


I can't seem to find any way to put some RTFD data into an NSData
object without reading it in from a file. How do I do it?

Thanks,

Mark
_______________________________________________
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: Getting RTFD data into an NSData object.
      • From: "Louis C. Sacha" <email@hidden>
  • Prev by Date: Re: Deleting duplicates in NSMutableArray
  • Next by Date: Re: Forwarding to Super
  • Previous by thread: Re: Deleting duplicates in NSMutableArray
  • Next by thread: Re: Getting RTFD data into an NSData object.
  • Index(es):
    • Date
    • Thread