UIPasteboard之pasteboardTypes

最近在做类似淘宝口令码的需求,发现个有关UIPasteboard的疑问。先看下面这个方法

#Summary

Returns whether the pasteboard holds data of the specified representation type.
# Discussion

This method works on the first item in the pasteboard. If there are other items, it ignores them. You can use this method when enabling or disabling the Paste menu command.

Starting in iOS 10, you can directly check which data types are present on a pasteboard by using the convenience methods described in [Checking for Data Types on a Pasteboard](apple-reference-documentation://hcPbJVw0Dk).

- (BOOL)containsPasteboardTypes:(NSArray *)pasteboardTypes;
 

Checking for Data Types on a Pasteboard

UIPasteboard之pasteboardTypes_第1张图片
image.png

上面的文档意思是containsPasteboardTypes用来判断pasteboard是否持有的数据类型,自iOS10以后可以使用hasImages、hasStrings等方法来替代。

然而问题是

当剪切板复制了一张图片,通过hasStrings判断结果为true,string内容为图片地址,这里就不举例说明。
此时想判断剪切板内容依然需要通过containsPasteboardTypes来判断。pasteboardTypes如Uniform Type Identifiers Overview、CoreServices/UTCoreTypes.h所示.

谢谢~

你可能感兴趣的:(UIPasteboard之pasteboardTypes)