clear pasteboard after 45 seconds
This commit is contained in:
parent
e1f3a08666
commit
2f3ccc9c07
4 changed files with 16 additions and 4 deletions
|
|
@ -113,6 +113,18 @@ class Utils {
|
|||
print(error)
|
||||
}
|
||||
}
|
||||
static func copyToPasteboard(textToCopy: String?, expirationTime: Double = 45) {
|
||||
guard textToCopy != nil else {
|
||||
return
|
||||
}
|
||||
UIPasteboard.general.string = textToCopy
|
||||
DispatchQueue.global(qos: .background).asyncAfter(deadline: DispatchTime.now() + expirationTime) {
|
||||
let pasteboardString: String? = UIPasteboard.general.string
|
||||
if textToCopy == pasteboardString {
|
||||
UIPasteboard.general.string = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// https://gist.github.com/NikolaiRuhe/eeb135d20c84a7097516
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue