How to Temboo with iOS


Temboo makes it easy to build iOS applications that connect to over 100 web-based resources and services (e.g. Facebook, Dropbox, US Census data) by standardizing how you interact with their Application Programming Interfaces (APIs). Don't worry if you're not familiar with APIs – with Temboo you don't have to worry about the details.

Here we'll show you how to use the Temboo iOS SDK to write a simple iOS class that uses Google's Geocoding API to retrieve the latitude and longitude for a specific address e.g., 104 Franklin St, New York City. What makes Temboo uniquely powerful and useful is that, once you know how to use one API, you know how to work with any API in our Library.

Before we get started, make sure that you've got iOS 7 and Xcode 6. For simplicity's sake, we'll create a command line tool that will print its results to the Xcode console. For an example of using Temboo with a UI-based application (as you would on an iPhone or iPad) check out our Facebook OAuth example.

Get Set up

1Create a new Xcode project: OS X > Application > Command Line Tool.

2Name it "GoogleGeocode", select "Objective-C" as the Language, and click "Next" (the other fields are optional and may be left blank) to save your new project.

3Download and extract the Temboo iOS SDK, noting where it's been saved.

4Click on the folder that contains your project's code (it should be called GoogleGeocode and contain a file called main.m), then select "Add Files to GoogleGeocode" from the File menu. Browse to where you saved the Temboo SDK, locate and click on the "core" folder inside the SDK "src" folder. Make sure that "copy items if needed" is unchecked and "Create groups" is selected, then and select "Add".

5Repeat the above steps to add the TMBGoogle.h and TMBGoogle.m files located in the SDk's src/library folder.

Test on our website

6 Log in to Temboo. If you don't already have an account, you can register for free here.

7 Go to the Google > Geocoding > GeocodeByAddress Choreo in our Library. Select iOS from the drop down menu at the top of the page.

8 Enter any address or ZIP code in the Address input field e.g., 104 Franklin Street, New York City.

9 Now click Generate Code to test the Choreo from our website. After a moment you'll see the data that Google sends back shown in the Output section.

Auto-Generate The Code

When you run any Choreo from our website, we automatically generate code that can be used to make the same API call many languages, including iOS. Here we'll show you how to use these snippets in your code.

10Scroll down to find the Code section of the Library page.

11Copy the code snippet and paste it into your project's main.m file, below the import statement for <Foundation/Foundation.h> and above the main method. The file structure should look like this:

#import <Foundation/Foundation.h>

...
*YOUR_TEMBOO_CODE_SNIPPET_GOES_HERE*
...

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        
        // insert code here...
        NSLog(@"Hello World!");
        
    }
    return 0;
}

12Finally, update the main method in main.m with the code below so that your file calls the Geocoding Choreo:

int main(int argc, const char * argv[]) {

    @autoreleasepool {
		// Create a new instance of our class
		GeocodeByAddress *tutorial = [[GeocodeByAddress alloc] init];
        
		// Run it
		[tutorial runGeocodeByAddressChoreo];
        
		// Only needed for command line tools, this simply keeps the program from exiting immediately
		[[NSRunLoop currentRunLoop] run];
	}
    return 0;
}

Try It Out

Each Choreo in the iOS SDK returns a ResultSet subclass that contains get methods tailored specifically to the outputs of that Choreo. Using the ResultSet, you can retrieve the raw data (typically XML or JSON) returned by a third-party API or relevant fields that we've parsed out of the response for you. Our snippets include code to print out the results returned by the Choreo in question.

13 Run the code and you will see the latitute and longitude printed to the console along with the full Choreo response. Congrats! You just ran your first Choreo from our iOS SDK.

What next?

Now you're ready to run any of our 2000+ Choreos in iOS. You're just a few steps away from making something extraordinary.

Once you've got your code up and running, you're ready to move on and do more. From monitoring your running applications, to moving your generated Temboo code to your preferred development environment and sharing it with colleagues, collaborators and friends - we've got you covered.

Need help?

We're always happy to help. Just email us at support@temboo.com, and we'll answer your questions.


Back