Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

in iOS development, I have often seen people creating a networking module to interact with their APIs.

This module generally sits on top of a networking framework like MKNetWorkKit or AFNetWorking.

In most of the cases, It's all about sending GET,POST request and parsing the response which is in most cases JSON.

What extra practical benefits that these libraries provide that an iOS developer should be leveraging which the plain Cocoa Networking APIs lack ?

I can understand RESTKit as one exception where it takes care of the conversion of JSON to native objects and also interfaces with Core Data but what about others ?

share|improve this question

One of the goals may be to abstract the way the network data is accessed.

Such abstraction can be very abstract:

public loadProducts(currentCategory) returns list of Product {
    var productsFactory = dataAccess.factory.createProductsFactory();
    var productsOfCategory = productsFactory.loadProducts(currentCategory);
    return productsOfCategory;

Here, the caller don't know if products are loaded from a database, an XML file, a REST request or something completely different. It makes it very easy to replace one data source by another, for example migrate all data from a REST service to a database.

Or the abstraction may be more transparent:

public doPostRequest(parameters) returns Stream {
    ... // Use library A to do the request. if you need to switch to library B later, this
        // is not an issue.

Here, the caller knows that the library is using a network resource. While being transparent, such library can still be useful when migrating from one way to do HTTP requests to another.

In .NET Framework, for example, there are at least three ways to do HTTP requests, not counting all the third party libraries one can use. Picking one way and sticking with it is a solution, but later, migrating to another implementation would be painful. Another solution is to create your own layer, abstracting the actual implementation: if a new version of .NET Framework will be released and you want to use a new way of doing HTTP requests, you change the code in one place.

share|improve this answer

What extra practical benefits that these libraries provide that an iOS developer should be leveraging which the plain Cocoa Networking APIs lack ?

Error handling, ease of use, simplified code, etc. NSURLConnection is a great class and very flexible, but if you take a look at NSURLConnectionDelegate you'll see that there are quite a few different network states that have to be handled. A good networking library takes care of much of that routine work.

share|improve this answer
So if someone is making a product of their own which they will be maintaining for a long time. Is it a good idea to write ur own wrapper library on top of NSURLConnection etc Or use one of these existing libraries ? – Amogh Talpallikar Jul 2 '13 at 7:04
@AmoghTalpallikar Depends... is there a 3rd party library that you like? Will it save you time compared to rolling your own? Can you live with the terms of the license? It's the same decision you'd make for any other library. – Caleb Jul 2 '13 at 7:27
hmm. yeah make sense. But is it still important for one to understand how NSURLConnection and related classes work ? Frankly speaking, it has been one year since I have been doing iOS dev. All I have been using is, always one of these libraries. I have never used NSURLConnection directly. I came from a JavaScript/AJAX background. Where I am used to creating an XMLHTTPRequest Object and give it a callback and done. I found working with these libraries, specially block based ones quite similar. So I was wondering, if I will ever need to understand NSURLConnection at all. – Amogh Talpallikar Jul 2 '13 at 7:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.