• 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
NSAttributedString to / from Pasteboard....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSAttributedString to / from Pasteboard....


  • Subject: NSAttributedString to / from Pasteboard....
  • From: Kartik Reddyreddy <email@hidden>
  • Date: Tue, 7 Sep 2010 09:43:53 -0400

Hi,

Is there a way to push/pop an NSAttributedString to/from Pasteboard...?? I
have an NSAttributedString with some custom attributes.

Currently I am using the following code to copy to the pasteboard.....

NSPasteboard *pb = [NSPasteboard generalPasteboard];


NSData *rtf = [aString RTFFromRange:NSMakeRange(0, [aString length])
documentAttributes:nil];


if (rtf)
{
[pb declareTypes:[NSArray arrayWithObject:NSRTFPboardType] owner:nil];
[pb setData:rtf forType:NSRTFPboardType];
}

and following code to retrieve from pasteboard

NSData* rtfData = [[NSPasteboard generalPasteboard] dataForType:
NSRTFPboardType];
if (rtfData) {
attrString = [[[NSAttributedString alloc] initWithRTF:rtfData
documentAttributes:nil] autorelease];
}

The above code results in loss of custom attributes.... Is there any other
method which can preserve custom attributes of NSAttributedString.


--
thanks and regards,

Abhinay Kartik Reddyreddy
46 Garden Circle, Apt # 2B,
Waltham , MA - 02452.
_______________________________________________

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

  • Follow-Ups:
    • Re: NSAttributedString to / from Pasteboard....
      • From: Ross Carter <email@hidden>
  • Prev by Date: Re: Core Graphics wants 10 petabytes of RAM
  • Next by Date: Small memory leaks in Cocoa guts
  • Previous by thread: Re: Core Graphics wants 10 petabytes of RAM
  • Next by thread: Re: NSAttributedString to / from Pasteboard....
  • Index(es):
    • Date
    • Thread