Can I receive a callback whenever an NSPasteboard is written to?

Unfortunately the only available method is by polling (booo!). There are no notifications and there’s nothing to observe for changed pasteboard contents. Check out Apple’s ClipboardViewer sample code to see how they deal with inspecting the clipboard. Add a (hopefully not overzealous) timer to keep checking for differences and you’ve got a basic (if clunky) solution that should be App-Store-Friendly.

File an enhancement request at bugreporter.apple.com to request notifications or some other callback. Unfortunately it wouldn’t help you until the next major OS release at the earliest but for now it’s polling until we all ask them to give us something better.

Leave a Comment