NSPasteboard(MOViewControllerPboard)


Abstract

NSPastboard additions to support reading and writing view controllers.

Discussion

NSPastboard additions to support reading and writing view controllers. MOViewControllers are written to the pasteboard using their state dictionaries as the persistent representation (by calling -stateDictionaryIgnoringContentState:). They are read back by recreating the controller hierarchies using the +viewControllerWithStateDictionary:ignoringContentState: factory method. This means that if you pass a controller through the pasteboard, you get a new equivalent controller hierarchy when you take it back out, you do NOT get the original controller hierarchy. Note that this also means that the new hierarchy will be equivalent only to the extent supported by its state dictionary. If a controller subclass fails to save and restore some aspect of its state, that aspect will be lost when the controller passes through the pasteboard.



Methods

setViewControllers:forType:
Writes the state dictionaries for the given controllers to the pasteboard with the given type.
viewControllersForType:
Recreates the controllers for the state dictionaries on the pasteboard.

setViewControllers:forType:

Writes the state dictionaries for the given controllers to the pasteboard with the given type.
- ( BOOL ) setViewControllers:
        (NSArray *) controllers forType:
        (NSString *) dataType;

Writes the state dictionaries for the given controllers to the pasteboard with the given type. This method calls -stateDictionaryIgnoringContentState:NO on each controller and puts the resulting dictionaries into an array which it then writes to the pasteboard. Usually, the pasteboard type will be MOViewControllerPboardType, but in specialized situations a more specialized pasteboard type can be defined and used instead.

Parameter Descriptions
controllers
An array of the controllers to be written.
dataType
The pasteboard type to write the data as (the written data is the same regardless of the type).
method result
Whether the write was successful.

viewControllersForType:

Recreates the controllers for the state dictionaries on the pasteboard.
- ( NSArray *) viewControllersForType:
        (NSString *) dataType;

Recreates the controllers for the state dictionaries on the pasteboard. This method calls +viewControllerWithStateDictionary:ignoringContentState: for each dictionarty in the array on the pasteboard to create corresponding new controller hierarchies. Usually, the pasteboard type will be MOViewControllerPboardType, but in specialized situations a more specialized pasteboard type can be defined and used instead. The data on the pasteboard should have been written with -setViewControllers:forType:

Parameter Descriptions
dataType
The pasteboard type to write the data as (the data format is expected to be the same regardless of the type).
method result
An array of the newly created MOViewControllers.

(Last Updated 3/20/2005)