Learning iPhone Programming
From Xcode to App Store
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.