In order to handle the backend, I’ll use Parse.com. Parse allows you to focus in the app while they handle the data persistence side. Parse has a few services, such as Push Notifications, Analytics and easy login systems with social networks. We’ll be using Core this time.

First you have to create an account in Parse. It’s free

image

Then in https://www.parse.com/apps, you have to create a new app by clicking the link Create New App. I’m going to call it TabBarApp to follow the previous example.

Once you put the name and press create, you are going to see four buttons in the bottom of the app square, click Quickstart:

image

Now click Data > Mobile > iOS > Swift > Existing Project.

Then in the set up guide, be sure you have the right app name in the right corner of the screen, in my case TabBarApp:

image

Now download the SDK here

Unzip it and drag and drop the Parse.framework and Bolts.framework into your Xcode project folder. Before that I prefer to create a new group to put all the frameworks there in order to have a cleaner project. To do that just go to Xcode and in the Project Navigator right click in your project name and hit New Group. Put and appropriate name.

image

When you drag and drop the frameworks make really sure that the Copy items if need it is checked. You are going to be sad after if you don’t.

Now you have to add the dependencies. To do that go to targets and then click your app’s name, then Build Phases and Link Binary With Libraries. there click the + button and add the following libraries:

AudioToolbox.framework CFNetwork.framework CoreGraphics.framework CoreLocation.framework QuartzCore.framework Security.framework StoreKit.framework SystemConfiguration.framework libz.tbd libsqlite3.tbd

image

Now we just have to connect the app with Parse. Go to AppDelegate.swift file and import Parse and Bolts:

Import Parse
Import Bolts

Then update the didFinishLaunchingWithOptions function and add the following code:

Parse.enableLocalDatastore()
Parse.setApplicationId([Your string App ID],
      clientKey: [Your string client key])

Now we have to test if everything is working. Go to your Controller View, in my case SectionVC and in ViewDidLoad() put:

let testObject = PFObject(className: "TestObject")
testObject["foo"] = "bar"
testObject.saveInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in
  print("Object has been saved.")
}

Then run your app. If you go to Core in Parse, you should see a new TestObject created.

image