How to get image data from a WebView into an NSData object? [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this questionI have a Cocoa app that embeds a WebView. The WebView loads html elements including images. I have the textual links for the images (e.g. "http://www.domain.com/path/image.jpg"), but what I want is the image data itself so I can put it in an NSData object and ship it off to Growl. The WebView must have this data since it has downloaded and rendered the image. How can I get at it?
Try this:
- Get the web view's main frame.
- Get the frame's data source.
- Ask the data source for the downloaded resource for the image URL.
- Get the resource's data.
精彩评论