UIKit.UIPasteboard Class
Support for the system pasteboard for cut, copy and paste.

See Also: UIPasteboard Members


[Foundation.Register("UIPasteboard", true)]
public class UIPasteboard : Foundation.NSObject



Pasteboards allow information to be shared across applications. The general pasteboard (accessible via the UIPasteboard.General property) is the system-wide pasteboard that applications use by default. Developers can also transfer information across their own applications (those that share their team ID) by creating their own pasteboards.

Setting Pasteboard Data

All operations that set the contents of the pasteboard clear any data that is currently stored there.

To set the pasteboard contents to Foundation.NSString, Foundation.NSArray, Foundation.NSDictionary, Foundation.NSDate, Foundation.NSNumber, UIKit.UIImage or Foundation.NSUrl use the UIPasteBoard.SetValue method.

To set the pasteboard contents to an image, use the UIPasteBoard.Image. property.

To set the pasteboard contents to a set of images, use the UIPasteBoard.Images. property.

To set the values to arbitrary data types, use the UIPasteBoard.SetData method.

You can use the convenience properties UIPasteboard.String, UIPasteboard.Strings, UIPasteboard.Image, UIPasteboard.Images, UIPasteboard.Url, UIPasteboard.Urls, UIPasteboard.Color and UIPasteboard.Colors to set and get strings, images, Urls or Colors on the pasteboard.

c# Example

// Setting the contents of the pasteboard to "Hello World"
// by specifying the UTI type for text.
var text = new NSString ("Hello world")
UIPasteboard.General.SetValue (text, MobileCoreServices.UTType.Text);

// Setting the contents of the pasteboard to "So hello"
// using the convenience property:
UIPasteboard.General.String = "So hello";

Pasteboard Types

Whenever possible, you should use an UTI type to set the type of the information that is being stored on the pasteboard. You can find a list of common iOS/Mac UTI types on the MobileCoreServices.UTType type.

UTI types are merely strings separated by dots. For example the UTI type for an image is "public.image". Apple maintains the "public.*" directory of UTI types.

Apple recommends that if you need to use your own data type to use an inverse domain to name them. For example, "com.xamarin.t-shirt-application.sales-information".

Related content


Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: