我可以获得iOS UIPasteboard的所有名称吗?

时间:2023-01-14 13:56:38

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?

要实例化UIPasteboard,需要一个名称。但我想知道UIPasteboard的所有名称。有没有办法知道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.

但名称可能是动态生成的带前缀的字符串。在这种情况下,我想知道所有具有相同前缀的名称。

3 个解决方案

#1


1  

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.

要以跨应用程序的方式使用UIPasteBoard和任何通用内容类型,不需要名称,而是调用+ [UIPasteBoard generalPasteboard],它返回粘贴板,该粘贴板接受您在复制粘贴操作中提供的大多数任何类型的内容。如果您想使用需要名称的初始化程序,请传入UIPasteboardNameGeneral以获得与上述相同的效果。

#2


0  

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.

您可以使用[UIPasteBoard generalPasteboard]访问一个公共粘贴板。这是普通的共享粘贴板,允许您在应用程序之间复制和粘贴内容。

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.

并且有名为粘贴板。没有API来获取现有粘贴板的名称。命名粘贴板就像私人粘贴板。它们可以跨应用程序共享,但每个应用程序必须就名称达成一致,或者名称可以从一个应用程序发送到另一个应用程序例如,这可以在用于从另一个应用程序启动一个应用程序的URL上完成。

#3


0  

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.

此外,您还需要已经具有粘贴板的名称才能使用它。

#1


1  

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.

要以跨应用程序的方式使用UIPasteBoard和任何通用内容类型,不需要名称,而是调用+ [UIPasteBoard generalPasteboard],它返回粘贴板,该粘贴板接受您在复制粘贴操作中提供的大多数任何类型的内容。如果您想使用需要名称的初始化程序,请传入UIPasteboardNameGeneral以获得与上述相同的效果。

#2


0  

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.

您可以使用[UIPasteBoard generalPasteboard]访问一个公共粘贴板。这是普通的共享粘贴板,允许您在应用程序之间复制和粘贴内容。

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.

并且有名为粘贴板。没有API来获取现有粘贴板的名称。命名粘贴板就像私人粘贴板。它们可以跨应用程序共享,但每个应用程序必须就名称达成一致,或者名称可以从一个应用程序发送到另一个应用程序例如,这可以在用于从另一个应用程序启动一个应用程序的URL上完成。

#3


0  

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.

此外,您还需要已经具有粘贴板的名称才能使用它。