osx - Paste gif image into NSPasteboard -


i developing osx application. want paste gif image pasteboard. how can that?

what have is

  • nsimage
  • nspasteboard

what want paste image pasteboard. able paste png image need paste gif image.


my existing code

let imageurl = imageobject.imageurl! let filename = imageurl.lastpathcomponent var saveurl = nsurl(string: "file://" + nstemporarydirectory()) saveurl = saveurl?.urlbyappendingpathcomponent(filename!) // have data let data = nsdata(contentsofurl: imageurl)  pasteboard.declaretypes([nstiffpboardtype], owner: nil) pasteboard.setdata(data!, fortype: "com.compuserve.gif") 

about 10 years ago same 1 asked how put gif onto nspasteboard? in apple discussion group , here answer. although 10 years old , nspasteboard methods changed since time answer still works. confess: advice bit dirty.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -