---
title: "[ios]获取网络状态"
author: "119568242"
date: "2013-06-23T11:35:46Z"
tags: []
categories: ["移动开发"]
slug: "ios"
draft: false
lastmod: "2013-06-23T11:35:46Z"
id: 1892975
url: "https://poolo.iteye.com/blog/1892975"
---

NetworkStatus netstatus = \[reachable currentReachabilityStatus];  
    switch (netstatus)  
        {  
                case NotReachable:  
                        // 没有网络连接  
                        reachableStatus = NSLocalizedString(@"No Network", "");  
                        break;  
                case ReachableViaWWAN:  
                        // 使用3G网络  
                        reachableStatus = @"GPRS/3G";  
                        break;  
                case ReachableViaWiFi:  
                        // 使用WiFi网络  
                        reachableStatus = @"WIFI";  
                        break;  
    }