Before your application attempts to make a network connection you need to know whether you have a network available, and depending on what you want to do you might also want to know whether the device is connected to a WiFi or cellular network. Helpfully, Apple has provided some sample code to deal with detecting current network status.
This screencast shows how to build a simple application that demonstrates the use of Apple's Reachability classs which I discuss in more detail, along with other networking topics, in Chapter 7 of the book.
Learn more about this topic from Learning iPhone Programming.
Get the hands-on experience you need to program for the iPhone and iPod Touch. With this easy-to-follow guide, you'll build several sample applications by learning how to use Xcode tools, the Objective-C programming language, and the core frameworks. Before you know it, you'll not only have the skills to develop your own apps, you'll know how to sail through the process of submitting apps to the iTunes App Store.