New xCode Project

Use xCode to create a new iOS project. This project can target any desired set of iOS devices.

Install Cocoapods

  1. Within your Xcode project directory, open a terminal window and enter in the following commands:

    • [sudo] gem install cocoapods
    • $ pod setup
  2. Add ClearBlade-API pod

    • Create a podfile for your project
      • Edit (vim, emaces, nano, etc) Podfile
    • Insert the following
      • pod ‘ClearBlade-iOS-API’
    • Install the pod
      • $ pod install
    • Open the .xcworkspace file

From now you will open the file with the extension .xcworkspace instead of the project file Open this from Finder or Xcode to start working on your app.

Sample Calls

  • To initialize the app call the class method [ClearBlade initSettingsWithAppKey:<app key> withAppSecret:<app secret>];

  • To fetch all from a collection

    • Initialize a collection
      col = [CBCollection collectionWithID:@”<collection ID>”];
    • Call the instance method
      col fetchWithSuccessCallback:^(CBQueryResponse *successfulResponse) {
      NSLog(@“%@”, [(CBItem *)[successfulResponse.dataItems objectAtIndex:0] objectForKey:@“name”]);
      NSMutableString *str = [[NSMutableString alloc] init];
      for (int i = 0; i < [successfulResponse.dataItems count]; i++) {
        [str appendFormat:@“%i: %@ \n”, i, [[(CBItem *)[successfulResponse.dataItems objectAtIndex:i] data] description]];
      NSLog(@“Str: %@“, str);
      } withErrorCallback:^(NSError *err, id stuff) {
      NSLog(@”%@”, [err description]);

Learn More

Try the iOS tutorial to learn more about the ClearBlade backend with examples for Objective C