copy string to clipboard in swift

Here's how to copy a string to the clipboard in Swift:

main.swift
let pasteboard = UIPasteboard.general
pasteboard.string = "Your string here"
77 chars
3 lines

You can replace "Your string here" with any String variable or literal to copy it to the clipboard. This code will automatically copy the string to the user's clipboard, and they can then paste it into another application.

gistlibby LogSnag