Revision control

Copy as Markdown

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import UIKit
extension UIPasteboard {
//
// As of iOS 11: macOS/iOS's Universal Clipboard feature causes UIPasteboard to block.
//
// (Known) Apple Radars that have been filed:
//
//
// Discussion on Twitter:
//
//
// To workaround this, urlAsync(callback:) makes a call of UIPasteboard.general on
// an async dispatch queue, calling the completion block when done.
//
func urlAsync(callback: @escaping (URL?) -> Void) {
DispatchQueue.global().async {
let url = URL(string: UIPasteboard.general.string ?? "", invalidCharacters: false)
callback(url)
}
}
}