Get Updates By E-mail 

Subscriber Counter
Article Written By:
Johann Dowa

Nice Simple Objective-C Networking Library With A Blocks based API

I’ve mentioned some great libraries for networking such as the popular MKnetworkKit, and AFNetworking which are great full featured networking libraries.

Today I came across a very interesting library providing a blocks based API using NSURL and NSConnection and built in the style of Apple’s CLGeocoder class.

What’s nice about this library is the simplicity, and that you are not forced to use a specific style.  The library also provides some extras for JSON and localization.

Here’s a basic JSON request taken from the readme:

NSURL *url = [NSURL URLWithString:@"https://gdata.youtube.com/feeds/api/standardfeeds/top_rated?alt=json?time=this_week"];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url];
[urlRequest setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
MBJSONRequest *jsonRequest = [[[MBJSONRequest alloc] init] autorelease];
[jsonRequest performJSONRequest:urlRequest completionHandler:^(id responseJSON, NSError *error) {
if (error != nil)
{
NSLog(@"Error requesting top-rated videos: %@", error);
}
else
{
NSArray *videos = [[responseJSON objectForKey:@"feed"] objectForKey:@"entry"];
for (NSDictionary *videoInfo in videos)
{
NSString *title = [[videoInfo objectForKey:@"title"] objectForKey:@"$t"];
NSString *author = [[[[videoInfo objectForKey:@"author"] objectAtIndex:0] objectForKey:@"name"] objectForKey:@"$t"];
NSLog(@"'%@' by %@", title, author);
}
}
}];

The library is MBRequest from Mobiata and can be found on Github here along with full usage instructions.

A nice choice if you’re looking for a simple networking library.

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments