NSAttributedString to / from Pasteboard....
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