Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download an save an image file on HDD with Cocoa

I'm building a program, and I'm quite confident using Objective-C, but I don't know how to programmatically download a file from the web and copy it on the hard drive. I started with :

NSString url = @"http://spiritofpolo.com/images/logo.png";
NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];

But then I don't know what to do with the data... that sucks, no ;) Can somebody help?

like image 717
Julien Avatar asked Dec 10 '22 15:12

Julien


1 Answers

You're close; the last thing you need is a call to -[NSData writeToFile:atomically:].

like image 166
fbrereto Avatar answered Dec 29 '22 22:12

fbrereto