##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
This template now uses the new Apigee iOS SDK
You'll have to do a few things to get this new framework to work.
- Build the framework by cloning the SDK and running the following script in the command line
./Scripts/framework.sh
- Add two linker flags into the build settings of your project
-ObjC -all_load
- Add the following frameworks to your project
- CoreGraphics
- CoreLocation
- CoreTelephony
- SystemConfiguration
- Find the
ApigeeiOSSDK.framework
in the build folder of the clone SDK.
- Setup segue to the new book view named
@"newBook"
- Setup outlets in detail view for the following properties
- Title
- Author
- UUID
- Setup client intialization
- Setup lookup of all books
- Make sure the objects appear in the
_objects
array - Set title text of cell to the book title
- Make sure the objects appear in the
- Setup Adding a new book
- Setup deleting a book
- 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];
}];
}
- Clone Repo
- Open in XCode
- Click Play