-
-
Save krisatkinson/b5dfad4c967972dd737c554ffbbadb66 to your computer and use it in GitHub Desktop.
Revisions
-
kristopherjohnson created this gist
Jan 11, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ import Foundation #if os(iOS) import UIKit #else import AppKit #endif /// Return string value currently on clipboard func getPasteboardContents() -> String? { #if os(iOS) let pasteboard = UIPasteboard.generalPasteboard() return pasteboard.string #else let pasteboard = NSPasteboard.generalPasteboard() return pasteboard.stringForType(NSPasteboardTypeString) #endif } /// Write a string value to the pasteboard func copyToPasteboard(text: String) { #if os(iOS) let pasteboard = UIPasteboard.generalPasteboard() pasteboard.string = text #else let pasteboard = NSPasteboard.generalPasteboard() pasteboard.clearContents() pasteboard.setString(text, forType: NSPasteboardTypeString) #endif }