OCPasteboard is modeled after NSPasteboard. NSPasteboard has support for multiple clipboards shared by all running applications. Data of any type can be put on the clipboard and multiple types can be put on at once. The general use-case for multiple types is if the data the user copies has more than one representation, supplying all possible representations allows the user to paste the data in the majority of places.

For instance, a user might want to copy an image out of a web view. The best practice would be to set the image data for the image type, set the image url for the url type and set some metadata about the file for the text type. Applications accepting pastes can decide which version they would like to grab. A text editing application might want to only grab the plain text, while a photo editing or viewing application would want to grab the image.

Some important caveats and differences between NSPasteboard and OCPasteboard:

  • OCPasteboard does not support owners.
    • The main use for owners is to lazily supply data the pasteboard. The idea being that you put the richest form of your data on the pasteboard and advertise that you could supply others if necessary. If an application pastes while your application is running, the pasteboard will ask for your less formatted data. Unfortunately, because of restrictions with the iPhone SDK, only one program can run at a time. Having an owner might still be useful, but for now it doesn't make much sense.
  • OCPasteboard does not support filtering.
    • NSPasteboard has the support for providing filter services for certain types of data and especially rich text. Most of the time this filtering is performed by the owner, and since there is no owner and the filter is unlikely to be called from inside the same application as the copy, filtering is expected to be done on the paste side. However, we are working on better ways to filter data and working on providing some common filters (i.e. from CFAttributedString to string).
    • Basically this makes following API is useless:
      + (NSArray *)typesFilterableTo:(NSString *)type;
      
      + (OCPasteboard *)pasteboardByFilteringFile:(NSString *)filename;
      + (OCPasteboard *)pasteboardByFilteringData:(NSData *)data ofType:(NSString *)type;
      + (OCPasteboard *)pasteboardByFilteringTypesInPasteboard:(OCPasteboard *)pboard;
      
  • The property list API methods do not work properly inside of the application.
    • This is a known issue so I do not suggest using the following API:
      - (BOOL)setPropertyList:(id)plist forType:(NSString *)dataType;
      - (id)propertyListForType:(NSString *)dataType;
      
  • The NSPasteboard API suggests not calling releaseGlobally and I'm not sure I would with OCPasteboard. That kind of thing is untested, but in memory emergencies, it might be worth a shot.

Those are just a few known issues I am working on. To see a complete list of issues or to add your own, visit Issues List.