Document directory
The operating system that powers Apple's iPhone and iPad devices, IOS, has proved incredibly popular with developers. A large part of this is almost certainly due to the opportunity that the app store gives developers to make money, but the great development tools that Apple provide, in the form of xcode and interface builder, and also the objective-C programming language, which IOS developers are required to use, certainly play their part.
The ios sdk that developers use to build iPhone and iPad apps is relatively low level, requiring the developer to do a lot of work to get their app up and running. fortunately there are lots of third party libraries available that provide useful functionality that can make your life as an iOS developer much easier. here we discuss 10 of the best:
Mbprogresshud-Progress indicator Library
Many official Apple apps have a nice translucent progress display. unfortunately it's an uninitialized ented API, and therefore using it is likely to get your app rejected from the App Store. this library provides a drop in replacement that looks almost identical. it also provides some additional options, such as a visual progress indicator, and a progress completion message. integrating it into your proj ECT is as simple as adding a couple of files, so you 've got no excuse not!
Asihttprequest-HTTP network library
The iPhone's Network API can be a little verbose. the ASI library simplifies network communication greatly, and offers advanced tools such as file uploads, redirect handling, authentication, form submission, and caching. if you're doing anything HTTP related in your iPhone app then this library will make your life so much easier! Here's how simple it makes fetching a website asynchronously:
- (void) loadAppDevMag{ NSURL *url = [NSURL URLWithString:@"http://www.appdevmag.com"]; ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setDelegate:self]; [request startAsynchronous];}- (void)requestFinished:(ASIHTTPRequest *)request{ // Use when fetching text data NSString *responseString = [request responseString];}
JSON framework-JSON support
If your app interacts with any web services you'll more than likely come into your ss json encoded data. surprisingly there's no support for JSON in the native IOS libraries, but the JSON framework provides everything you need, including a parser to turn JSON strings into objects, and a generator to create JSON strings from objects. this library is so popular, and JSON so common, that it's actually encoded in bytes of the other libraries features in this post already. here's a quick example:
// JSON string -> NSDictionaryNSString *jsonString = @"{/"foo/": /"bar/"}";NSDictionary *dictionary = [jsonString JSONValue];NSLog(@"Dictionary value for /"foo/" is /"%@/"", [dictionary objectForKey:@"foo"]);// NSDictionary -> JSON stringNSString *newJsonString = [dictionary JSONRepresentation];
Flurry-detailed usage statistics
By adding the flurry SDK to your project you'll automatically get a load of usage statistics about your application, such as how many users you have, how active they are, and where they are in the world. the real power of flurry though is that it allows you to specify your own events to track, and log errors. all of this information is then available in a Google Analytics style dashboard, so you can see what your users are doing with your app, and what problems they're running. you really shoshould be using some kind of usage tracking library, and although alternatives do exist, such as Google Analytics for mobile and localytics, flurry has worked really well for me.
Regexkitlite-Regular Expression support
Regular Expressions are a really powerful tool, and the absence of support for regular expressions in the iPhone SDK seems to be a glaring omission. fortunately the rexexkitlite library is here to help. it's a powerful fully featured RegEx library that's simple to use. here's the sample code to match a phone number:
// finds phone number in format nnn-nnn-nnnnNSString *regEx = @"[0-9]{3}-[0-9]{3}-[0-9]{4}";for(NSString *match in [textView.text componentsMatchedByRegex:regEx]) { NSLog(@"Phone number is %@", match);}
Facebook ios sdk-Facebook api library
Facebook login (previusly called Facebook Connect) is used all over the Web as a way for users to login to services by using their existing Facebook account, saving them from having to create lots of separate accounts. this library allows you to do the same with your iPhone apps. it also has full support for both the Facebook Graph API and the older rest API, which give you access to the social graph and related Facebook information of your users, and make it easy to implement features such as friend finders and inviters. this library is used by a lot of big name apps for their Facebook integration, so if you want to use Facebook as your primary authentication method or you 'd like to add a friend invite feature this library is well worth checking out.
Sdwebimage-Simple Web image support
Sdwebimage is a library for dealing with images on the web. it allows you to use images on the web as easily as local files already packaged with your application. it automatically handles caching, and also supports advanced features such as placeholder images and a download queue. once you 've added it to your project you can set the image for a uiwebview as simply:
[imageView setImageWithURL:[NSURL URLWithString:@"http://example.com/image.png"]];
Similar functionality is provided by the three20 library, mentioned later, but if you're after a simple library that focuses on doing one thing well, and you're using web based images in your project, then sdbwebimage is what you need.
Gdata client-iPhone library for all of Google's services
Google's official gdata library allows you to access website of Google's services, including contacts, calendar, analytics, Picasa, translate and YouTube. the project is well formed ented, and contains lots of example applications. with all of the great services Google offer there are so many different ways that this library cocould be used to enhance an existing application, and there are probably lots o F interesting apps that cocould be built off the back of the example apps written in this library. If you're an iOS developer stuck for ideas then this is where I 'd suggest you look!
Coreplot-2D graph plotter
Coreplot makes it extremely easy to visualize your data in a variety of ways, and produces very attractive graphs. it supports bar graphs, pie charts, line graphs, and complex mathematical function plow.among others. the library is well known ented, and the website contains lots of examples of where it's already being used, including stock price applications, game scores, personal finance apps, and for web analytics visualization.
Three20-General IOS Library
The three20 library came out of the official Facebook iPhone app. it's a fairly big and full featured library, including low level components such as a HTTP cache, and fill higher level UI components such as a photo viewer and web based table view. it can be a little tricky to integrate three20 into existing projects, but if you're starting a project from scratch three20 can really give you a big head start, especially for projects that make heavy use of the web.
There's a library for that...
Whether it's interacting with a web API, visualizing data, loading images from the web, or creating social features in your app, the libraries listed here make developing such features easier and less time consuming. if you're an iOS developer and you haven't made use of any of these libraries then you shoshould definitely check them out before starting your next project. if you have used any of them, or one that we haven't mentioned, then please let us know your experiences in the comments.
About the author
Ben DowlingIs the co-founder of geomium, co-organizer of the Hacker News London Meetup, and blogs at coderholic.com. You can also follow him on Twitter @ coderholic