The SCNetworkReachability
interface can help you with that. Basically, you create a so-called reachability reference and then call SCNetworkReachabilityGetFlags
on it to get information about the connection.
The returned flags include kSCNetworkReachabilityFlagsIsWWAN
, which tells you whether you are connected via WiFi or the cell network. AFAIK it cannot be used to tell the difference between 2G and 3G, though.
See Apple's Reachability sample app for an implementation. In most cases, you should be able to directly use the included Reachability
class in your project.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…