Chapter 9. Address Book Example
The first full example in this book shows how to write an application around Twitter and the Address Book. The goal here is to import our Twitter contacts into our address book and learn new tricks as we go along.
Let’s begin by creating a MacRuby application using Xcode. For that, start Xcode and choose the MacRuby template. In the template settings, set the Product Name to TwitterContactImporter and use “clear” or “deselect” or “disable” the Document-Based and Core Data options.
User Interface
I personally find it easier to start by working on the UI, and then adding the required code. Click on the .xib file to edit the interface, then select the Window object, as shown in Figure 9-1.
Figure 9-1. Initial UI
We are going to add a button that will automatically import our Twitter contacts. Once the contacts are imported, we will display the list of our contacts and let the user search for a specific contact.
To start, we need to use an image to put on our button. Head to the Twitter logos and icons site and download the logo of your choice. Save the image as twitter_logo.png somewhere on your hard drive. Once the image is saved, drag and drop it in Xcode into the Resources folder. An option screen like the one shown in Figure 9-2 will open.
Figure 9-2. Import ...
Get MacRuby: The Definitive Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.