Coder Social home page Coder Social logo

digideskio / apigee-app-services-books-start Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mdobson/apigee-app-services-books-start

0.0 1.0 0.0 3.08 MB

A small template app for iOS books. We have code in the directions portion of the README!

Objective-C 100.00%

apigee-app-services-books-start's Introduction

##iOS Template app for App Services

This is a basic Books app that will be built using Objective-C, XCode, and StoryBoards.

Some important point code snippets.

Things that the template is missing

SDK Setup

This template now uses the new Apigee iOS SDK

You'll have to do a few things to get this new framework to work.

  1. Build the framework by cloning the SDK and running the following script in the command line ./Scripts/framework.sh
  2. Add two linker flags into the build settings of your project -ObjC -all_load
  3. Add the following frameworks to your project
  4. CoreGraphics
  5. CoreLocation
  6. CoreTelephony
  7. SystemConfiguration
  8. Find the ApigeeiOSSDK.framework in the build folder of the clone SDK.

TODOs for completion

  1. Setup segue to the new book view named @"newBook"
  2. Setup outlets in detail view for the following properties
    • Title
    • Author
    • UUID
  3. Setup client intialization
  4. Setup lookup of all books
    • Make sure the objects appear in the _objects array
    • Set title text of cell to the book title
  5. Setup Adding a new book
  6. Setup deleting a book
  7. Bonus! Implement a search bar in the master view that uses a query to look a book up by title.

Initializing our Objetive-C SDK.

static NSString *orgName = @"mdobson";
static NSString *appName = @"books";
self.client =  [[ApigeeClient alloc] initWithOrganizationId:orgName applicationId:appName];

Creating an entity with a NSMutableDictionary Literal

[[self.client dataClient] createEntity:@{@"type":@"book", @"title":book[@"title"], @"author":book[@"author"]} completionHandler:^(ApigeeClientResponse *response){
        if (response.transactionState == kApigeeClientResponseSuccess) {
            [_objects insertObject:response.response[@"entities"][0] atIndex:0];
        } else {
            [_objects insertObject:@{@"title":@"error"} atIndex:0];
        }
        [self.tableView reloadData];
    }];

Deleting a book

[[self.client dataClient] removeEntity:@"book"
                  entityID:entity[@"uuid"]
         completionHandler:^(ApigeeClientResponse *response){
             if (response.transactionState == kApigeeClientResponseSuccess) {
                 [_objects removeObjectAtIndex:indexPath.row];
                 [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
             }
         }];

Retrieving books from your UserGrid account.

//Getting all of your books without a filtering query.
  [[self.client dataClient] getEntities:@"book" query:nil
                        completionHandler:^(ApigeeClientResponse *result){
                            if (result.transactionState == kApigeeClientResponseSuccess) {
                                _objects = result.response[@"entities"];
                            } else {
                                _objects = @[];
                            }
                            [self.tableView reloadData];
                        }];

Implementing a search bar delegate method to search for books with a query

-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
    ApigeeQuery * query = [[ApigeeQuery alloc] init];
    [query addRequirement:[NSString stringWithFormat:@"title='%@'", searchBar.text]];
    [[self.client dataClient] getEntities:@"book"
                                    query:query
                        completionHandler:^(ApigeeClientResponse *result){
                            if (result.transactionState == kApigeeClientResponseSuccess) {
                                _objects = result.response[@"entities"];
                            } else {
                                _objects = @[];
                            }
                            [self.tableView reloadData];
                        }];
}
  1. Clone Repo
  2. Open in XCode
  3. Click Play

apigee-app-services-books-start's People

Contributors

mdobson avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.