You want to display a message to your users in the form of an alert. This could be used to ask them to confirm an action, ask for their username and password, or simply let them enter some simple text that you can use in your app.
If you are an iOS user, you have most certainly already seen an alert view. Figure 2-1 depicts an example.
Figure 2-1. An alert view telling the user that she needs an active Internet connection
The best way to initialize an alert view is, of course, by using its designated initializer:
When this alert view is displayed to the user, she will see something similar to that shown in Figure 2-2:
Figure 2-2. A simple alert view displayed to the user
In order to display an alert view to the user, we use the alert
show method. Let’s have a look
at the description for each of the parameters that we passed to the
initializer of the alert view:
The string that the alert view will display on the top when
it is shown to the user. This string is
Title in Figure 2-2.
The actual message that gets displayed ...