stigi / ClipboardViewer

The Apple ClipboardViewer Sample Code brought back to life.

Home Page:https://developer.apple.com/library/archive/samplecode/ClipboardViewer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

{\rtf1\ansi\ansicpg1252\cocoartf974
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Monaco;}
{\colortbl;\red255\green255\blue255;}
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\ql\qnatural

\f0\b\fs48 \cf0 Clipboard Viewer\
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\ql\qnatural

\fs28 \cf0 \
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\ql\qnatural

\b0\fs24 \cf0 This small application shows the contents of any clipboard. A combo box lets you choose the clipboard to be examined (either from the built-in list, or by entering the name of an arbitrary clipboard); the list of types on the selected clipboard are displayed in a table view; and clicking on a type in the table view shows the data for that type in a text view.\
\
The app has six custom classes:\
\
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\ql\qnatural

\b \cf0 PasteboardController
\b0 \
The central controller object driving the UI and getting data from the clipboard. This class shows:\
- Interacting with the clipboard (getting types list; getting data for a given type; checking to see if pasteboard was changed between accesses).\
- Interacting with the simple UI of the app, including an NSComboBox.\
- Use of simple properties.\
- User interface validation.\
- Presenting errors.\
- Using NSSavePanel as a sheet.\
\

\b LazyDataTextStorage
\b0 \
Subclass of NSTextStorage, used as the backing store for the NSTextView which displays the contents. Upon loading the nib the NSTextStorage for this view is replaced with an instance of LazyDataTextStorage. LazyDataTextStorage uses a string and an attributes dictionary for its backing store; the string is retained, not copied, allowing the three lazily-evaluated NSString subclasses (below) to actually behave lazily. Note that LazyDataTextStorage is not editable and thus it overrides the editing methods of NSTextStorage to do nothing.\
\

\b ASCIIString, HexString, and HexAndASCIIString\
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\ql\qnatural

\b0 \cf0 Three NSString subclasses for the three ways clipboard data is displayed in the application. These classes are ordered by complexity; ASCIIString is a very simple example of an NSString subclass, while HexAndASCIIString uses a much more complicated implementation of its 
\f1\fs20 \CocoaLigature0 getCharacters:range:
\f0\fs24 \CocoaLigature1  method to interpret ten-byte sequences as lines and only process the lines that are needed.\
\
\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\ql\qnatural

\b \cf0 PasteboardTypeTransformer
\b0 \
A subclass of NSValueTransformer. This class converts pasteboard types based on four-character codes (like the old HFS type and creator codes) to be a bit more human-readable; it interprets the four bytes as native characters and puts them at the beginning of the pasteboard type's string. Other pasteboard types are just passed through. Although the conversion looks sticky, this is a reasonably good example of creating one's own value transformer.\
}

About

The Apple ClipboardViewer Sample Code brought back to life.

https://developer.apple.com/library/archive/samplecode/ClipboardViewer/


Languages

Language:Objective-C 100.0%