Takayuki Sato
Takayuki Sato

Reputation: 1043

Can I get all names of iOS UIPasteboard?

To instantiate UIPasteboard, a name is needed. But I want to know all names of UIPasteboard. Are there any way to know all names of UIPasteboard?

For example, if the name of pasteboard is already known, following is enough.

UIPasteboard* pb = [UIPasteboard pasteboardWithName:[NSString stringWithFormat:@"NameOfPasteboard"];

But the name may be dynamically generated string with prefix. In such case, I want to know all names which has the same prefix.

Upvotes: 3

Views: 1157

Answers (3)

CodaFi
CodaFi

Reputation: 43330

To use UIPasteBoard with any generic content type in an inter-application manner, a name is not required, rather a call to +[UIPasteBoard generalPasteboard], which returns the pasteboard that accepts most any kind of content you provide in a copy-paste operation. If you would like to use the initializer that requires a name, pass in UIPasteboardNameGeneral to achieve the same effect as above.

Upvotes: 1

Sam
Sam

Reputation: 390

textViewer.text = [UIPasteboard generalPasteboard].string;

An example.

Also you need to already have the name of the pasteboard in order to use one that requires it.

Upvotes: 0

rmaddy
rmaddy

Reputation: 318804

There is one public pasteboard that you get access to with [UIPasteBoard generalPasteboard]. This is the normal, shared paste board that allows you to copy and paste stuff between apps.

And there are named pasteboards. There is no API to get the names of existing pasteboards. Named pasteboards are like private pasteboards. They can be shared across apps but each app must agree on the name or the name can be sent from one app to another. This can be done on a URL used to launch one app from another, for example.

Upvotes: 0

Related Questions