UIPasteboard Class

Definition

Support for the system pasteboard for cut, copy and paste.

[Foundation.Register("UIPasteboard", true)]
[ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.TvOS, ObjCRuntime.PlatformArchitecture.All, null)]
public class UIPasteboard : Foundation.NSObject
type UIPasteboard = class
    inherit NSObject
Inheritance
UIPasteboard
Attributes

Remarks

Pasteboards

Pasteboards allow information to be shared across applications. The general pasteboard (accessible via the 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 NSString, NSArray, NSDictionary, NSDate, NSNumber, UIImage or NSUrl use the SetValue(NSObject, String) method.

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

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

To set the values to arbitrary data types, use the M:UIKit.UIPasteBoard.SetData* method.

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

//
// 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, MonoTouch.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 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".

Constructors

UIPasteboard(IntPtr)

A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

UIPasteboard(NSObjectFlag)

Constructor to call on derived classes to skip initialization and merely allocate the object.

Properties

Automatic

Key indicating that pasteboard types should have their Uniform Type Identifiers determined automatically.

ChangeCount

The number of times this UIPasteBoard's contents have changed. Read-only.

ChangedNotification

Notification constant for Changed

ChangedTypesAddedKey

Represents the value associated with the constant UIPasteboardChangedTypesAddedKey

ChangedTypesRemovedKey

Represents the value associated with the constant UIPasteboardChangedTypesRemovedKey

Class (Inherited from NSObject)
ClassHandle

The handle for this class.

Color

The color of the first pasteboard item.

Colors

The colors used by all pasteboard items.

Count

The number of items on this UIPasteBoard. Read-only.

DebugDescription

A developer-meaningful description of this object.

(Inherited from NSObject)
Description

Description of the object, the Objective-C version of ToString.

(Inherited from NSObject)
General

The general pasteboard, used for copy-paste operations.

Handle

Handle (pointer) to the unmanaged object representation.

(Inherited from NSObject)
HasColors

Gets whether the Colors array is non-empty.

HasImages

Gets whether the Images array is non-empty.

HasStrings

Gets whether the Strings array is non-empty.

HasUrls

Gets or sets whether the pasteboard contains URLs.

Image

Retrieves or sets the image of the first pasteboard item.

Images

The images of all the pasteboard items.

IsDirectBinding (Inherited from NSObject)
IsProxy (Inherited from NSObject)
ItemProviders

Gets or sets an array of all the item providers for the pasteboard.

Items

The pasteboard items on this UIPasteBoard.

Name

The name of this UIPasteBoard. Read-only.

Persistent

Developers should not use this deprecated property.

RemovedNotification

Notification constant for Removed

RetainCount

Returns the current Objective-C retain count for the object.

(Inherited from NSObject)
Self (Inherited from NSObject)
String

The string value of the first pasteboard item.

Strings

The string values of all the pasteboard items.

Superclass (Inherited from NSObject)
SuperHandle

Handle used to represent the methods in the base class for this NSObject.

(Inherited from NSObject)
TypeListColor

Represents the value associated with the constant UIPasteboardTypeListColor

TypeListImage

Represents the value associated with the constant UIPasteboardTypeListImage

TypeListString

Represents the value associated with the constant UIPasteboardTypeListString

TypeListURL

Represents the value associated with the constant UIPasteboardTypeListURL

Types

The representations types of the first item on the pasteboard.

Url

The URL of the first pasteboard item.

Urls

The URLs of all the pasteboard items.

Zone (Inherited from NSObject)

Methods

AddItems(NSDictionary[])

Appends items to the content of this UIPasteBoard.

AddObserver(NSObject, NSString, NSKeyValueObservingOptions, IntPtr)

Registers an object for being observed externally (using NSString keyPath).   Observed changes are dispatched to the observer’s object ObserveValue(NSString, NSObject, NSDictionary, IntPtr) method.

(Inherited from NSObject)
AddObserver(NSObject, String, NSKeyValueObservingOptions, IntPtr)

Registers an object for being observed externally (using string keyPath).   Observed changes are dispatched to the observer’s object ObserveValue(NSString, NSObject, NSDictionary, IntPtr) method.

(Inherited from NSObject)
AddObserver(NSString, NSKeyValueObservingOptions, Action<NSObservedChange>)

Registers an object for being observed externally using an arbitrary method.

(Inherited from NSObject)
AddObserver(String, NSKeyValueObservingOptions, Action<NSObservedChange>)

Registers an object for being observed externally using an arbitrary method.

(Inherited from NSObject)
AwakeFromNib()

Called after the object has been loaded from the nib file. Overriders must call base.AwakeFromNib().

(Inherited from NSObject)
BeginInvokeOnMainThread(Action) (Inherited from NSObject)
BeginInvokeOnMainThread(Selector, NSObject)

Invokes asynchrously the specified code on the main UI thread.

(Inherited from NSObject)
Bind(NSString, NSObject, String, NSDictionary) (Inherited from NSObject)
Bind(String, NSObject, String, NSDictionary)
Obsolete.
(Inherited from NSObject)
BindingInfo(String)
Obsolete.
(Inherited from NSObject)
BindingOptionDescriptions(String)
Obsolete.
(Inherited from NSObject)
BindingValueClass(String)
Obsolete.
(Inherited from NSObject)
CommitEditing() (Inherited from NSObject)
CommitEditing(NSObject, Selector, IntPtr) (Inherited from NSObject)
ConformsToProtocol(IntPtr)

Invoked to determine if this object implements the specified protocol.

(Inherited from NSObject)
Contains(String[], NSIndexSet)

Whether the pasteboard elements specified by itemSet contain data of the specified pasteboardTypes.

Contains(String[])

Whether this UIPasteBoard holds data of the specified type.

Copy()

Performs a copy of the underlying Objective-C object.

(Inherited from NSObject)
DangerousAutorelease() (Inherited from NSObject)
DangerousRelease() (Inherited from NSObject)
DangerousRetain() (Inherited from NSObject)
DataForPasteboardType(String)

The data on this UIPasteBoard for the specified representation type.

DidChange(NSKeyValueChange, NSIndexSet, NSString)

Indicates a change occurred to the indexes for a to-many relationship.

(Inherited from NSObject)
DidChange(NSString, NSKeyValueSetMutationKind, NSSet) (Inherited from NSObject)
DidChangeValue(String)

Indicates that a change occurred on the specified key.

(Inherited from NSObject)
Dispose()

Releases the resources used by the NSObject object.

(Inherited from NSObject)
Dispose(Boolean)

Releases the resources used by the NSObject object.

(Inherited from NSObject)
DoesNotRecognizeSelector(Selector)

Indicates that this object does not recognize the specified selector.

(Inherited from NSObject)
Equals(NSObject) (Inherited from NSObject)
Equals(Object) (Inherited from NSObject)
ExposedBindings() (Inherited from NSObject)
FromName(String, Boolean)

Returns the UIPasteBoard for the specified name, optionally creating one if it doesn't exist.

GetBindingInfo(NSString) (Inherited from NSObject)
GetBindingOptionDescriptions(NSString) (Inherited from NSObject)
GetBindingValueClass(NSString) (Inherited from NSObject)
GetDataForPasteboardType(String, NSIndexSet)

The data objects in the specified pasteboard items that have the specified representation type.

GetDictionaryOfValuesFromKeys(NSString[])

Retrieves the values of the specified keys.

(Inherited from NSObject)
GetHashCode()

Generates a hash code for the current instance.

(Inherited from NSObject)
GetMethodForSelector(Selector) (Inherited from NSObject)
GetNativeField(String)
Obsolete.
(Inherited from NSObject)
GetNativeHash() (Inherited from NSObject)
GetUnique()

The application pasteboard identified by the unique system-generated name.

GetValue(String)

Retrieves data of the specified type.

GetValuesForPasteboardType(String, NSIndexSet)

Returns the objects on this UIPasteBoard that have the specified representation type.

Init() (Inherited from NSObject)
InitializeHandle(IntPtr, String) (Inherited from NSObject)
InitializeHandle(IntPtr) (Inherited from NSObject)
Invoke(Action, Double) (Inherited from NSObject)
Invoke(Action, TimeSpan) (Inherited from NSObject)
InvokeOnMainThread(Action) (Inherited from NSObject)
InvokeOnMainThread(Selector, NSObject)

Invokes synchrously the specified code on the main UI thread.

(Inherited from NSObject)
IsEqual(NSObject) (Inherited from NSObject)
IsKindOfClass(Class) (Inherited from NSObject)
IsMemberOfClass(Class) (Inherited from NSObject)
ItemSetWithPasteboardTypes(String[])

A set whose values are the indices of those pasteboard items that have the specified representation type.

MarkDirty()

Promotes a regular peer object (IsDirectBinding is true) into a toggleref object.

(Inherited from NSObject)
MutableCopy()

Creates a mutable copy of the specified NSObject.

(Inherited from NSObject)
ObjectDidEndEditing(NSObject) (Inherited from NSObject)
ObserveValue(NSString, NSObject, NSDictionary, IntPtr)

Indicates that the value at the specified keyPath relative to this object has changed.

(Inherited from NSObject)
PasteBoardTypesForSet(NSIndexSet)

The representation types for all the items in the specified set.

PerformSelector(Selector, NSObject, Double, NSString[]) (Inherited from NSObject)
PerformSelector(Selector, NSObject, Double)

Invokes the selector on the current instance and if the obj is not null, it passes this as its single parameter.

(Inherited from NSObject)
PerformSelector(Selector, NSObject, NSObject) (Inherited from NSObject)
PerformSelector(Selector, NSObject) (Inherited from NSObject)
PerformSelector(Selector, NSThread, NSObject, Boolean, NSString[]) (Inherited from NSObject)
PerformSelector(Selector, NSThread, NSObject, Boolean) (Inherited from NSObject)
PerformSelector(Selector) (Inherited from NSObject)
PrepareForInterfaceBuilder() (Inherited from NSObject)
Remove(String)

Removes the specified application pasteboard.

RemoveObserver(NSObject, NSString, IntPtr)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath and context.

(Inherited from NSObject)
RemoveObserver(NSObject, NSString)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath.

(Inherited from NSObject)
RemoveObserver(NSObject, String, IntPtr)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath and context.

(Inherited from NSObject)
RemoveObserver(NSObject, String)

Stops the specified observer from receiving further notifications of changed values for the specified keyPath.

(Inherited from NSObject)
RespondsToSelector(Selector)

Whether this object recognizes the specified selector.

(Inherited from NSObject)
SetData(NSData, String)

Sets the data for the specified representation type in this UIPasteBoard.

SetItemProviders(NSItemProvider[], Boolean, NSDate)

Sets the item providers using the specified details.

SetItems(NSDictionary<NSString,NSObject>[], NSDictionary)

Adds to the pasteboard, with the specified privacy .

SetItems(NSDictionary<NSString,NSObject>[], UIPasteboardOptions)

Adds to the pasteboard.

SetNativeField(String, NSObject)
Obsolete.
(Inherited from NSObject)
SetNilValueForKey(NSString)

Sets the value of the specified key to null.

(Inherited from NSObject)
SetObjects(INSItemProviderWriting[], Boolean, NSDate)

Sets the item provider array to the specified objects with the specified details.

SetObjects(INSItemProviderWriting[])

Sets the item provider array to the specified objects.

SetValue(NSObject, String)

Sets the value for the specified representation type in this UIPasteBoard.

SetValueForKey(NSObject, NSString)

Sets the value of the property specified by the key to the specified value.

(Inherited from NSObject)
SetValueForKeyPath(IntPtr, NSString)

A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

(Inherited from NSObject)
SetValueForKeyPath(NSObject, NSString)

Sets the value of a property that can be reached using a keypath.

(Inherited from NSObject)
SetValueForUndefinedKey(NSObject, NSString)

Indicates an attempt to write a value to an undefined key. If not overridden, raises an NSUndefinedKeyException.

(Inherited from NSObject)
SetValuesForKeysWithDictionary(NSDictionary)

Sets the values of this NSObject to those in the specified dictionary.

(Inherited from NSObject)
ToString()

Returns a string representation of the value of the current instance.

(Inherited from NSObject)
Unbind(NSString) (Inherited from NSObject)
Unbind(String)
Obsolete.
(Inherited from NSObject)
ValueForKey(NSString)

Returns the value of the property associated with the specified key.

(Inherited from NSObject)
ValueForKeyPath(NSString)

Returns the value of a property that can be reached using a keypath.

(Inherited from NSObject)
ValueForUndefinedKey(NSString)

Indicates an attempt to read a value of an undefined key. If not overridden, raises an NSUndefinedKeyException.

(Inherited from NSObject)
WillChange(NSKeyValueChange, NSIndexSet, NSString)

Indicates that the values of the specified indices in the specified key are about to change.

(Inherited from NSObject)
WillChange(NSString, NSKeyValueSetMutationKind, NSSet) (Inherited from NSObject)
WillChangeValue(String)

Indicates that the value of the specified key is about to change.

(Inherited from NSObject)

Extension Methods

GetDebugDescription(INSObjectProtocol)
GetAccessibilityCustomRotors(NSObject)

Gets the array of UIAccessibilityCustomRotor objects appropriate for this object.

SetAccessibilityCustomRotors(NSObject, UIAccessibilityCustomRotor[])

Sets the array of UIAccessibilityCustomRotor objects appropriate for this object.

Applies to

See also