2011-07-07 33 views
13

有没有一种方法可以跟踪iPhone上的蜂窝数据使用情况?有很多的应用程序,其不相同,如“DATAMAN”和“DataUsage”iPhone - 跟踪蜂窝数据使用情况

基本上我在找一个纲领性的方式来获得存储在设置信息 - >常规 - >使用

任何帮助将不胜感激。

+0

我也问了这一点,但没有答复尚未:http://stackoverflow.com/questions/5274805/iphone-ipad-data-usage-tracking HTTP:/ /stackoverflow.com/questions/4375441/how-to-keep-track-of-the-network-traffic-on-3g-wifi-on-an-ios-device http://stackoverflow.com/questions/4380806/ iphone-data-usage-monitoring http://stackoverflow.com/questions/4746053/how-does-dataman-iphone-app-work-in-the-background – phi

+0

@Irene:嗯,这是不好的,因为我看到的应用程序应用商店做相同的功能.. !!! – Unicorn

+0

检查也http://stackoverflow.com/questions/4313358/measure-network-traffic-programmatically-on-iphone-他们建议getifaddrs,但我一直没能找到一个工作的例子。 – phi

回答

2

您可以查询每个网络接口的数据通过它。

+1

但是如何查询网络? –

6

要检查蜂窝网络使用此

- (bool) hasCellular { 
    struct ifaddrs * addrs; 
    const struct ifaddrs * cursor; 
    bool found = false; 
    if (getifaddrs(&addrs) == 0) { 
     cursor = addrs; 
     while (cursor != NULL) { 
      NSString *name = [NSString stringWithUTF8String:cursor->ifa_name]; 
       if ([name isEqualToString:@"pdp_ip0"]) 
        found = true; 
      } 
      cursor = cursor->ifa_next; 
     } 
     freeifaddrs(addrs); 
    } 
    return found; 
} 
+0

我不认为Unicorn想知道设备连接到蜂窝网络。我认为他们对**有多少**数据通过该界面感兴趣。 – Nate

+5

http://stackoverflow.com/questions/7946699/iphone-data-usage-tracking-monitoring/8014012#8014012检查数据使用情况 –