If you want to make life easiest for yourself, use a third-party framework, AFNetworking.
If you are writing this code yourself (which I wouldn't necessarily suggest) you can use NSURLSession
if supporting Mac OS X 10.9 and later only, or use NSURLConnection
if you need to support prior versions.
For information on the Apple technologies, see the URL Loading System Programming Guide.
Personally, I've done it both ways. I have "rolled my own" set of classes which continue to evolve even now, more than a year later. I have also used AFNetworking, too. I learned a ton doing my own class framework, and pedagogically, that's a valuable exercise. But recognize that it takes a lot of effort to get up to speed on all of the subtleties of good asynchronous networking code.
Sure, one can use, for example, NSURLConnection
method sendAsynchronousRequest
easily enough, but if you want progress updates, handle authentication challenges, form application/x-www-urlencoded
requests, use NSOperation
-based requests, etc., you quickly find yourself in the non-trivial amount of code. AFNetworking is not without a few flaws, it's generally a very robust networking class that I heartily recommend for newer developers.