Graphics Programs Reference
In-Depth Information
1
A Simple iOS Application
In this chapter, you are going to write your first iOS application. You probably won't un-
derstand everything that you are doing, and you may feel stupid just going through the mo-
tions. But going through the motions is enough for now. Mimicry is a powerful form of
learning; it is how you learned to speak, and it is how you'll start iOS programming. As
you become more capable, you can experiment and challenge yourself to do creative things
on the platform. For now, just do what we show you. The details will be explained in later
chapters.
When you are writing an iOS application, you must answer two basic questions:
• How do I get my objects created and configured properly? (Example: “I want a
button here entitled Show Estimate .”)
• How do I deal with user interaction? (Example: “When the user presses the button,
I want this piece of code to be executed.”)
Most of this topic is dedicated to answering these questions.
When an iOS application starts, it puts a view on the screen. You can think of this view as
the background on which everything else appears: buttons, labels, etc. Buttons and labels
are also views. In fact, anything that can appear to the user is a view.
The iOS SDK is an object-oriented library, and views are represented by objects. Each
view is an instance of one of several subclasses of the UIView class. For example, a but-
ton is an instance of UIButton , which is a subclass of UIView . (We will discuss objects,
instances, and classes in detail in Chapter 2 . )
For your first iOS application, you will visually create and configure your view objects.
This application, called Quiz , will show a user a question and then reveal the answer when
the user presses a button. Pressing another button will show a new question ( Figure 1.1 ).
Figure 1.1 Your first application: Quiz
 
Search WWH ::




Custom Search