Building an app template – iOS 6 all features

Template for an iOS 6 app, for an iPhone device, with Core Data and AFNetworking.


Create a new project, named “Classes”.

Empty Application template. iPhone device. Use ARC yes, un-check/clear the other two checkboxes. Save it wherever you want.

Add icons for your app, named Icon@2x.png, and Icon.png (for non-Retina displays).

Add a new rich text file to the project’s root, named “ReadMe”. Use this for documentation.

In AppDelegate.m, remove the unnecessary code in the application:didFinishLaunchingWithOptions: method.

In the Classes > Supporting Files group, create a new Core Data Data Model, named “ObjectModel.

In the Classes > Supporting Files group, create a new storyboard file, for an iPhone device, named MainStoryboard.storyboard. On the project settings TARGETS screen, select this new storyboard on the “Main Storyboard” drop-down.

build_phases_link_library_with_librariesStill on the project settings TARGET screen, select the “Build Phases” tab. Add these frameworks to the “Link Library With Libraries” area:

  • CoreData.framework
  • SystemConfiguration.framework
  • MobileCoreServices.framework
  • Security.framework

Drag-and-drop to reorder the frameworks to match the image on the right.

In the Project Navigator, select the added frameworks, then drag-and-drop them on top of the “Frameworks” group.

Copy the latest 1.x version of the AFNetworking classes into the project. These source code files should be placed in their own group (named “AFNetworking”).

Add the CDStack class from another project.

Add the DataCreator class from another project. Remove code that won’t be useful in the template.

Add the Model class from another project. Remove code that won’t be useful in the template.

Create a Utilities class. Add utility methods – date converters and so on – that will be useful in an app.

In the project’s pch file, add ‘import’ statements for:

  • <CoreData/CoreData.h>
  • <SystemConfiguration/SystemConfiguration.h>
  • <MobileCoreServices/MobileCoreServices.h>
  • “Model.h”
  • “AFNetworking.h”
  • “Utilities.h”

Create a class named “ClientTemplate” that is a subclass of AFHTTPClient. Its .h interface code should look like this:

#import "AFHTTPClient.h"

@interface ClientTemplate : AFHTTPClient

+ (id)sharedClient;


Its .m implementation should look like this:

#import "ClientTemplate.h"
#import "AFJSONRequestOperation.h"

#define BaseURL @""

@implementation ClientTemplate

// Initialize
// The dispatch_once function will ensure that the singleton pattern is followed
+ (id)sharedClient
    static ClientTemplate *__sharedInstance = nil;
    static dispatch_once_t onceToken;

    dispatch_once(&onceToken, ^{
        __sharedInstance = [[ClientTemplate alloc] initWithBaseURL:[NSURL URLWithString:BaseURL]];
    return __sharedInstance;

- (id)initWithBaseURL:(NSURL *)url
    self = [super initWithBaseURL:url];
    if (self)
        // Configuration
        // e.g. can also set token header, and other settings
        [self registerHTTPOperationClass:[AFJSONRequestOperation class]];
        [self setDefaultHeader:@"Accept" value:@"application/json"];
    return self;



Gather the following classes together, and put them in a group named “Persistence”. That will enable your Project Navigator to look cleaner and less cluttered:

  • CDStack
  • DataCreator
  • Model
  • ClientTemplate
  • Utilities







  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: