Working with the Clipboard on OSX

By reeset / On / In C#, code, Programming

Coming from the Windows and Linux world — the object where data is copy and pasted from is called the Clipboard.  Not so in OSX.  In OSX, this is referred to as the NSPasteBoard.  Should you need to get string data on and off of it – use the following:


private static string[] pboardTypes = new string[] { "NSStringPboardType" };
public void SetClipboardText(string text)
	NSPasteboard.GeneralPasteboard.DeclareTypes(pboardTypes, null);
	NSPasteboard.GeneralPasteboard.SetStringForType(text, pboardTypes[0]);

public string GetClipboardText()
	return NSPasteboard.GeneralPasteboard.GetStringForType(pboardTypes[0]);