detectPatterns(for:inItemSet:completionHandler:)
Determines whether pasteboard items match the specified patterns, without notifying the user.
Declaration
func detectPatterns(for patterns: Set<UIPasteboard.DetectionPattern>, inItemSet itemSet: IndexSet?, completionHandler: @escaping (Result<[Set<UIPasteboard.DetectionPattern>], any Error>) -> ())Parameters
- patterns:
The patterns to detect on the pasteboard.
- itemSet:
An index set with each integer value identifying a pasteboard item positionally in the pasteboard. Pass
nilto detect patterns in all pasteboard items. - completionHandler:
A closure that the system invokes after detecting patterns on the pasteboard. The closure receives a
Resultinstance that contains either an array with the patterns found on the pasteboard or an error if detection failed. If theResultinstance contains an array, the index of each element in the array corresponds to the pasteboard item index specified initemSet.
Discussion
Because this method only detects for the presence of patterns and does not read the contents of the pasteboard, the system doesn’t notify the user about reading the contents of the pasteboard.