Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

Chapter 19. Pasteboards > Drag and Drop - Pg. 686

686 Chapter 19. Pasteboards This iterates over all of the types that it knows how to handle, in the order in which it prefers them. A rich text view, for example, would prefer RTF data but would accept plain strings if RTF is not available. Remember that the sender parameter here is the sender of the action message--typically the Paste menu item--and not the pasteboard or object providing the data. Copying Fonts If you want to implement Copy Style functionality in your application, then you need to use the NSFontPboard pasteboard. You might be wondering how you copy a font onto this pasteboard, since it does not support the NSCoding protocol and cannot give a data representation of itself. The solution to this is to create a one-character NSAttributedString and set the font on this. You then create an RTF representation of the attributed string and store it in the pasteboard. When you want to get a font back, you create an attributed string from the data and then read the font attribute. 19.8 Drag and Drop