NSPasteboard is the Cocoa class representation for clipboard data, allowing information to be copied and pasted within and between programs. NSPasteboards also represent information that is being dragged within or among programs.
Questions tagged [nspasteboard]
161 questions
56
votes
6 answers
Can I receive a callback whenever an NSPasteboard is written to?
I've read Apple's Pasteboard Programming Guide, but it doesn't answer a particular question I have.
I'm trying to write a Cocoa application (for OS X, not iOS) that will keep track of everything that is written to the general pasteboard (so,…

Adrian Petrescu
- 16,629
- 6
- 56
- 82
23
votes
2 answers
Swift 3 copy string to clipboard
How do you Copy a string to Clipboard in macOS 10.12 with Xcode 8 and Swift 3?
I am not able to find any reference.

Nisba
- 3,210
- 2
- 27
- 46
17
votes
2 answers
NSPasteboard and simple custom data
I'm having a really difficult time trying to get NSPasteboard to work, so forgive me for my lack of understanding.
All I want is a simple way to write and retrieve from the pasteboard a NSUInteger value that is only for my application. All I am…

AndyTang
- 547
- 7
- 24
17
votes
2 answers
get string from nspasteboard
maybe it's been a long night but I am not able to understand how to check the clipboard for strings
I have been reading the NSPasteboard documentation..
could some one help me out?

BlockReader
- 641
- 1
- 8
- 17
16
votes
5 answers
Reading from the clipboard with Swift 3 on macOS
I'm a beginner with Swift, and I'm trying to figure out how can I read what has been copied to the clipboard On macOS (Swift 3)? I've searched a lot but can't seem to find anything that works.
A few of the things I've tried from online:
var…

John
- 371
- 1
- 3
- 11
13
votes
3 answers
How to save off the pasteboard contents first and restore them afterward?
I have a faceless Mac OS X app which needs to copy selection from other apps. I achieve this by simulating CMD+C keystrokes. It works perfectly.
But there is a, I think it's critical, side effect. It'll override users' pasteboard without their…

Lucidus
- 161
- 1
- 5
9
votes
3 answers
How to paste text from one app to another using Cocoa?
I have read about NSPasteBoard in the Apple documentation, and how it allows for applications to write into the PasteBoard and allow other applications to read that text and use it.
Could someone tell me how to paste text from am application (that…

Navi Sidhu
- 198
- 1
- 5
9
votes
5 answers
How do I handle multiple file drag/drop from Finder in Mac OS X 10.5?
I need to get the URLs of all files dragged/dropped into my application from Finder.
I have a Cocoa app running on 10.6 which does this by using the new 10.6 NSPasteboard APIs which handle multiple items on the pasteboard. I'm trying to backport…

robottobor
- 11,595
- 11
- 39
- 37
8
votes
4 answers
Drag Files come across Sandbox(__CFPasteboardIssueSandboxExtensionForPath)
I processed drag operation from browser view to custom view.It work well in snow lepoard,but not in Mountain Lion with sandbox.
in browser view:
NSMutableArray* urls = [[[NSMutableArray alloc] init] autorelease];
..............put some NSUrl to…

Achilles Wang
- 121
- 7
7
votes
1 answer
Disable Universal Clipboard temporarily
iOS and macOS have a built in feature called Universal Clipboard that syncs the clipboard's content across devices using iCloud.
NSPasteboard.general.clearContents()
NSPasteboard.general.writeObjects("Test 123")
I would like to write something to…

Daniel
- 1,473
- 3
- 33
- 63
6
votes
1 answer
How to Allow Users To Drag Files Out of Cocoa App
I am working on a macOS application that involves creating a folder in a temporary directory.
How can I allow users to drag a folder icon off of the Cocoa app and onto their desktop (or into Finder and other apps) so that dropping it will actually…

Jake3231
- 703
- 8
- 22
6
votes
2 answers
How can I check that the NSPasteboard is updated?
I'm automating a copy command to place some text on the pasteboard every second or so - unfortunately this is my only way of accessing the text, which is in another application. After copying, I access the pasteboard text and process it.
Sometimes,…

Ben Packard
- 26,102
- 25
- 102
- 183
6
votes
2 answers
Determine the source application of current pasteboard content
Several OSX clipboard managers from AppStore show the ability to determine the source-application of content that was copied to the clipboard.
I am writing some simple clipboard observer and would like to show the source-application icon near the…

UJey
- 1,442
- 11
- 15
5
votes
1 answer
How much memory can the general NSPasteboard occupy?
The general NSPasteboard stores stuff that the user has copied. For example, like 100 images and 1000 words. Is there a limit to the size of the general NSPasteboard such that the user can copy say.. 99 images maximum?
What defines this limit? RAM…

hollow7
- 1,506
- 1
- 12
- 20
5
votes
1 answer
How to use NSPasteboard with kPasteboardTypeFileURLPromise for copy/paste?
My application would like to add a promise to the pasteboard for a file that is stored remotely, and may never be pasted—similar to pasting a file copied from a session controlling a VM or other remote system. Ideally, a user can paste in a Finder…

Byteboon
- 120
- 9