Nuwe Parse Server - iOS SDK Getting Started


#1

In order to get up and running with the iOS SDK for the Parse-Server Service (see http://community.healthhackers.co/t/feature-nuwe-parse-server/75 for how to quickly setup Parse Server for your Nuwe app), here’s a quickstart guide (thanks to the team at Parse).

Install

  1. Our recommended Installation method is via cocoapods

Add pod 'Parse' to your Podfile and run pod install

Make sure, after successfully installing via cocoapods, that you close the .xcproject and open the new .xcworkspace from now on.

Connect to your Parse-Server

Objective C

  1. Open your AppDelegate.m and add the following:
#import <Parse/Parse.h>
 
@implementation AppDelegate
 
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
 
// Initialize Parse.
[Parse initializeWithConfiguration:[ParseClientConfiguration configurationWithBlock:^(id<ParseMutableClientConfiguration> configuration) {
   configuration.applicationId = @"YOUR_PARSE_APP_ID";
   configuration.server = @"https://parse.nuwe.co:YOUR_PORT/parse";
}]];
 
// ...
}
 
// ...

Compile and run!

Swift

Open up your AppDelegate.swift and update it like so:

import Parse
import Bolts
 
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
 
  func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Initialize Parse.
    let configuration = ParseClientConfiguration {
        $0.applicationId = "YOUR_PARSE_APP_ID"
        $0.server = "https://nuwe.co:YOUR_PORT/parse"
    }
    Parse.initializeWithConfiguration(configuration)
 
    // ...
}
 
// ...

Compile and run!

Test the SDK

Objective C

First make sure to include our SDK libraries from your .h file:

#import <Parse/Parse.h>

Then copy and paste this code into your app, for example in the viewDidLoad method (or inside another method that gets called when you run your app):

PFObject *testObject = [PFObject objectWithClassName:@"TestObject"];
testObject[@"foo"] = @"bar";
[testObject saveInBackground];

Run your app. A new object of class TestObject will be sent to the Parse Server and saved.

Swift

First make sure to include our SDK imports at the top of your .swift files:

import Parse

Then copy and paste this code into your app, for example in the viewDidLoad function (or inside another function that gets called when you run your app):

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

Run your app. A new object of class TestObject will be sent to the Parse Server and saved.

Where to go from here?

Review the iOS Guide
Review the Parse-Server iOS API Reference