如何以编程方式获取iphone的MAC地址

编程入门 行业动态 更新时间:2024-10-28 20:26:25
本文介绍了如何以编程方式获取iphone的MAC地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有谁知道如何以编程方式获取iPhone的MAC地址和IP地址?

Does anyone know how to programmatically get an iPhone's MAC address and IP address?

推荐答案

注意从iOS7开始,您无法再检索设备MAC地址。将返回一个固定值,而不是实际的MAC

NOTE As of iOS7, you can no longer retrieve device MAC addresses. A fixed value will be returned rather than the actual MAC

我偶然发现的事情。最初来自这里我修改了它有点干净了。

Somthing I stumbled across a while ago. Originally from here I modified it a bit and cleaned things up.

IPAddress.h IPAddress.c

使用它

InitAddresses(); GetIPAddresses(); GetHWAddresses(); int i; NSString *deviceIP = nil; for (i=0; i<MAXADDRS; ++i) { static unsigned long localHost = 0x7F000001; // 127.0.0.1 unsigned long theAddr; theAddr = ip_addrs[i]; if (theAddr == 0) break; if (theAddr == localHost) continue; NSLog(@"Name: %s MAC: %s IP: %s\n", if_names[i], hw_addrs[i], ip_names[i]); //decided what adapter you want details for if (strncmp(if_names[i], "en", 2) == 0) { NSLog(@"Adapter en has a IP of %s", ip_names[i]); } }

适配器名称也因模拟器/设备而异作为设备上的wifi或单元格。

Adapter names vary depending on the simulator/device as well as wifi or cell on the device.

更多推荐

如何以编程方式获取iphone的MAC地址

本文发布于:2023-11-27 20:24:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639477.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方式   地址   iphone   MAC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!