Fork me on GitHub

What is it?

This project is inspired on HTML5 boilerplate.

  • It is intended to provide a base of code to start with
  • It is not intended to be a framework
  • It is intended to be modified and extended by the developer to fit their needs
  • It includes solid third-party libraries if needed to not reinvent the wheel

I want it now!                 Fork


What is supported

iOS Boilerplate is tested on iPhone / iPod Touch devices with iOS 4.0 or greater. In the future it might support universal applications (iPhone + iPad)

At the moment iOS Boilerplate is just an XCode project. Is planned to be released as a true XCode template in the near future.


What's included

iOS Boilerplate includes helper classes and examples about the following topics:

  • HTTP requests and an image cache (both in-memory and disk-based)
  • UITableViews and UITableViewCells: fast scrolling, async images, pull-down-to-refresh, swipeable cells,...
  • A built-in browser so your users don't leave your application when they browse to a certain URL
  • Maps and locations: directions between two points, autocomplete a location, etc.



iOS Boilerplate includes ASIHTTPRequest AFNetworking, a great library for handling HTTP requests. See HTTPHUDExample to view a simple example of how to use this library.

iOS Boilerplate also includes AFURLCache that implements both in-memory and in-disk caches (great for images!). AFURLCache has been developed by steipete.

See AsyncImageExample.m for a basic example on how to load images.

If you are interested in loading async images in a UITableView there is a complete example about async images inside UITableViewCells. See AsyncCellImagesExample.m




FastCells

Inspired on this article of Atebits iOS Boilerplate includes a base class for implementing cells with fast scrolling. The base class is FastCell. There are some examples that extend this class. See AsyncCellImagesExample, VariableHeightExample and SwipeableTableCellExample.

Pull-down-to-refresh

iOS Boilerplate includes EGOTableViewPullRefresh but simplifies its use. You can extend ListViewController.

// This is the core method you should implement
- (void)reloadTableViewDataSource {
	_reloading = YES;

    // Here you would make an HTTP request or something like that
    // Call [self doneLoadingTableViewData] when you are done
    [self performSelector:@selector(doneLoadingTableViewData) withObject:nil afterDelay:3.0];
}

You just need to implement something like the above code and initialize the self.table object. You can initialize it with InterfaceBuilder (drop a UITableView component and make the link between the outlet and the component). You should also implement at least the UITableViewDataSource protocol. For a complete example see PullDownExample.

Swipeable cells

There is an example of how to implement a swipeable UITableViewCell extending FastCell. Some code is also needed in the ViewController. See SwipeableTableViewExample for a complete example.




Thanks to nbuggia you can now open URLs inside your application just opening them as always:

[[UIApplication sharedApplication] openURL:url];

A new viewController will be shown without exiting your app. However, what happens if you really need to open a URL in Safari? No worries, just use this method instead:

[(MyApplication*)[UIApplication sharedApplication] openURL:url forceOpenInSafari:YES];

What if you don't want this to be the default behaviour? What if you want to open URLs by default in Safari? Just edit main.m. Put nil instead of @"MyApplication"

And now, to use the built-in web browser explicitly use this:

BrowserViewController *bvc = [[BrowserViewController alloc] initWithUrls:url];
[self.navigationController pushViewController:bvc animated:YES];
[bvc release];



Directions

There is an example of how to calculate the directions between two points using the Google Maps API and showing it on a MKMapView using map overlays. See DirectionsExample.m.

Autocomplete locations

There is an example of how to autocomplete locations using the Google Maps API. See AutocompleteLocationExample.m.





JSONKit

iOS Boilerplate includes JSONKit that is a fast library for generating and parsing JSON documents.

SVProgressHUD

iOS Boilerplate includes SVProgressHUD that is a simple-to-use HUD component. It is used in HTTPHUDExample

DictionaryHelper

This helper class adds some methods to the NSDictionary class. These methods are usful for safe manipulation of data.

- (NSString*) stringForKey:(id)key;
- (NSNumber*) numberForKey:(id)key;
- (NSMutableDictionary*) dictionaryForKey:(id)key;
- (NSMutableArray*) arrayForKey:(id)key;

These method ensure that the object retrieved is of the desired type, otherwise return nil. Also NSNull is never returned. These methods are very useful when manipulating objects returned by JSONKit or any other JSON library.

StringHelper

This helper class adds some methods to the NSString class. The most useful are:

- (NSString*)trim; returns the original NSString but without white spaces at the beginning or at the end.

- (NSString*)urlEncode; url-encodes the original NSString.

- (NSString*)sha1; calculates the SHA1 of the given NSString.

DataHelper

This helper class adds one method to the NSData class. This method is - (NSString*)hexString; and returns a NSString in hexadecimal representing the content of the original NSData object.




QuickDialog

QuickDialog allows you to create HIG-compliant iOS forms for your apps without having to directly deal with UITableViews, delegates and data sources. Fast and efficient, you can create forms with multiple text fields, or with thousands of items with no sweat!

IBAForms

IBAForms is a framework for building data entry screens on the iPhone. You can quickly make forms using the built-in form field types or create your own custom fields and the user interfaces used to enter data for them

PSStackedView

PSStackedView: put your UIViewControllers in a stack, inspired by Twitter's iPAD UI




CocoaControls

CocoaControls Custom UI Controls for iOS and Mac OS X

iOS Frameworks

iOS Frameworks A curated catalog of iOS frameworks and classes for the pragmatic iOS developer