iOS engineer who likes clean, simple designs and sans-serif.

Loading

Parse [Cheatsheet]

This is updated as of Parse v1.2.17, Ruby v2.0.0, and RubyGems v2.2.0.

  1. Installing Ruby and Rubygems (and HomeBrew).

      ruby -v
      brew install ruby
      gem -v
      sudo gem update --system

    – Alternatives to Parse: Stackmob, Appcelerator, Applicasa, Kinvey

  2. Installing Parse with Cocoapods (cocoapods.org)

    – From command line, run ‘sudo gem install cocoapods’
    – Create Podfile with:

      platform :ios, '7.0'
      pod 'Parse'

    – From command line, run ‘pod install’
    – Remember to only use *.xcworkspace and not *.xcodeproj

  3. Manually Installing Parse (parse.com/quickstart)

    [Without Cocoapods]
    – Download SDK, unzip and copy to Frameworks directory.
    – Select project => “Build Phases” => “Link Binary With Libraries”
    – Manually add libraries (Required for Parse):

      AudioToolbox.framework
      CFNetworking.framework
      CoreLocation.framework
      libz.1.1.3.dylib
      MobileCoreServices.framework
      QuartzCore.framework
      Security.framework
      StoreKit.framework
      SystemConfiguration.framework
  4. Setting Up Workspace with Parse (parse.com/quickstart)

    – Login to your Parse account.
    – Create a new application and go to quickstart.
    – In .pch file (or AppDelegate.m), add

      #import <Parse/Parse.h>

    – Get code snippet from parse.com and in LLAppDelegate.m, paste the following inside the application:didFinishLaunchingWithOptions: function:

      [Parse setApplicationId:@"YOUR_APPLICATION_ID_HERE"
                  clientKey:@"YOUR_CLIENT_KEY_HERE"];

    – Run Command Shift K to clean project

  5. Creating a PFObject:

      PFObject *loginCreditionals = [PFObject objectWithClassName:@"LoginCredentials"];
      loginCreditionals[@"name"] = self.usernameTextField.text;
      loginCreditionals[@"password"] = self.passwordTextField.text;

      [loginCreditionals saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
        if (succeeded) {
          UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Save" message:@"Your object saved" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
          [alertView show];
        } else if (error) {
          NSLog(@"%@", error);
        }
      }];

    – Login to parse.com and verify object created.

  6. Querying a PFObject:

      @property (strong, nonatomic) NSMutableArray *credentials;
      PFQuery *queryForCredentials = [PFQuery queryWithClassName:@"LoginCredentials"];
      [queryForCredentials findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (!error) {
          self.credentials = [objects mutableCopy];
          [self.tableView reloadData];
        };
      }];

    – Output data in UI and test in Simulator.

Leave a Comment