The iOS Apprentice 4
StoreSearch (Part 1)
By Matthijs Hollemans
Version 1.4
One of the most common things that mobile apps do, is talking to a server on the internet.
If you’re writing mobile apps, you need to know how to upload and download data. In
this lesson you’ll learn how to do HTTP GET requests to a web service, how to parse
JSON data, and how to download files such as images.
We are going to build an app that lets you search the iTunes store. Of course, your iPhone
already has apps for that (“App Store” and “iTunes” to name two), but what’s the harm
in writing another one? Apple has made a web service available for searching the entire
iTunes store and we’ll be using that to learn about networking.
The finished app will look like this:
The finished StoreSearch app
We will add search capability to our old friend, the table view. There is an animated
pop-up with extra information when you tap an item in the table. And when you flip the
iPhone over to landscape, the layout of the app completely changes to show the search
results in a different way.
There is also an iPad version of the app:
1
The app on the iPad
Our to-do list for building StoreSearch will roughly be as follows:
• Create a table view (yes, again!) with a search bar.
• Perform a search on the iTunes store using their web service.
• Understand the response from the iTunes store and put the search results into our
table view.
• Each search result has an artwork image associated with it. We’ll need to download
these images separately and place them in the table view as well.
• Add the pop-up screen with extra info that appears when you touch an item.
• When you flip to landscape, the whole user interface changes and we’ll show all of
the icons in a paging scroll view.
• Add support for other languages. Having your app available in languages besides
English dramatically increases its audience.
• Make the app universal so it runs on the iPad.
2
This chapter fills in the missing pieces and rounds off the knowledge you have obtained
from the previous tutorials. I will also show you how to distribute your app to beta testers
(so-called Ad Hoc Distribution) and how to submit it to the App Store.
We have a lot of work ahead of us, so let’s get started!
3
In the beginning...
Fire up Xcode and make a new project. Choose the Single View Application template
and fill in the options as follows:
• Product Name: StoreSearch
• Company Identifier: com.yourname
• Class Prefix: leave this empty
• Device Family: iPhone
• Use Storyboard: uncheck this, we won’t be using Storyboards
• Use Automatic Reference Counting: yes
• Include Unit Tests: no
We’re not using Storyboards for this app but regular nibs and Interface Builder, just like
we did for Bull’s Eye. Storyboards would have worked just fine, but I want to show you
that nibs are still a valid choice.
When you save the project, Xcode gives you the option to create a local Git repository.
We’ve ignored this option thus far but now you should enable it:
Creating a git repository for the project
4