我搜索了这个主题,但发现很少有帮助的细节.有了这些细节,我试着按如下方式编写一些代码.
注意:请将此帖中分享的详细信息与其他帖子进行比较,然后再将其标记为DUPLICATE,而不仅仅是主题.
- (NSArray *)getDataCountersForType:(int)type {
BOOL success;
struct ifaddrs *addrs = nil;
const struct ifaddrs *cursor = nil;
const struct sockaddr_dl *dlAddr = nil;
const struct if_data *networkStatisc = nil;
int dataSent = 0;
int dataReceived = 0;
success = getifaddrs(&addrs) == 0;
if (success) {
cursor = addrs;
while (cursor != NULL) {
if (cursor->ifa_addr->sa_family == AF_LINK) {
dlAddr = (const struct sockaddr_dl *) cursor->ifa_addr;
networkStatisc = (const struct if_data *) cursor->ifa_data;
if (type == WiFi) {
dataSent …Run Code Online (Sandbox Code Playgroud) 有没有办法跟踪iPhone上的手机数据使用情况?有很多应用程序像'Dataman'和'DataUsage'那样做同样的事情
基本上我正在寻找一种编程方式来获取存储在设置 - >常规 - >用法中的信息
任何帮助将不胜感激.