cocoa - How do I turn an NSMutableData into an image in a view? -


I downloaded a .jpg file from the Internet with this code:

  NSURLRequest * TheRequest = [NSRR request request with url: [NSUr URL youththring: @ "http://cvcl.mit.edu/hybrid/cat2.jpg"]] ;; NSURLConnection * theConnection = [[NSURLConnection alloc] initWithRequest: theRequest Representative: Self]; ReceivedData = [[NSMutableData data] is maintained); // etc etc  

Everything works fine I do not know how to handle the data say that I have created an image view in the IB, I am about to display the image How would I go? Here's the last bit:

  - (zero) connectionDifffish: Loading: (NSURLConnection *) Connection {*** ******} Do something with data ***** **** .. but how NSLog (@ "succeeded! Get% d bytes of data", [received data length]); // release connection, and data object [connection release]; [Received Data Release]; }  

Assume that your NSImageView a IBotlet is called imageView , you should be able to initialize the image using the received data and then set the image view to display the image.

  NSImage * image = [[NSImage alloc] initWithData: Acquired data]; [ImageView Set Image: Image]; [Image release];  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -