Thursday, March 17, 2011

Some Useful iOS Libraries

AppDev Magazine previously listed some useful iOS libraries. Below are the libraries listed and a couple of additional libraries that I have used.

A lot of the libraries in the above list are very useful, very current and widely used so there should be a lot of examples around on how to use them. I recommend the ASIHttpRequestShareKitFlurry , GData Objective-C ClientFacebook iOS SDKRegexKitListTouchJSONJSON Framework for Objective-CCore Plot and SDWebImage because I have used them recently. The rest I haven't used recently so I cannot recommend them. You can also read 10 iOS Libraries to make your life easier. for more information about some of these libraries.

MBProgressHUD – Progress Indicator LibraryMany official Apple apps have a nice translucent progress display. Unfortunately it’s an undocumented 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 project is as simple as adding a couple of files, so you’ve got no excuse not to!

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:@""];
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 across 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 included in many of the other libraries features in this post already. Here’s a quick example:
// JSON string -> NSDictionary
NSString *jsonString = @"{\"foo\": \"bar\"}";
NSDictionary *dictionary = [jsonString JSONValue];
NSLog(@"Dictionary value for \"foo\" is \"%@\"", [dictionary objectForKey:@"foo"]);
// NSDictionary -> JSON string
NSString *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 into. You really should be using some kind of usage tracking library, and although alternatives do exist, such as Google Analytics for Mobileand 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-nnnn
NSString *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 (previously 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 just 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 as:
[imageView setImageWithURL:[NSURL URLWithString:@""]];
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 many of Google’s services, including contacts, calendar, analytics, picasa, translate and YouTube. The project is well documented, and contains lots of example applications. With all of the great services Google offer there are so many different ways that this library could be used to enhance an existing application, and there are probably lots of interesting apps that could be built off the back of the example apps included 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 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 plotting among others. The library is well documented, 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 many 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.

No comments:

Post a Comment

Popular Posts