Domanda

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.

È stato utile?

Soluzione

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.

Altri suggerimenti

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.

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top