IOS 获取已连接的wifi信息的实现代码
程序员文章站
2023-12-21 11:36:04
ios 获取已连接的wifi信息的实现代码
首先需要 #import
ios 获取已连接的wifi信息的实现代码
首先需要 #import <systemconfiguration/captivenetwork.h>
+ (id)fetchssidinfo { nsarray *ifs = (id)cncopysupportedinterfaces(); nslog(@"%s: supported interfaces: %@", __func__, ifs); id info = nil; for (nsstring *ifnam in ifs) { info = (id)cncopycurrentnetworkinfo((cfstringref)ifnam); nslog(@"%@ => %@", ifnam, info); if (info && [info count]) { break; } [info release]; } [ifs release]; return [info autorelease]; }
arc 版本:
+ (id)fetchssidinfo { nsarray *ifs = (__bridge_transfer id)cncopysupportedinterfaces(); nslog(@"%s: supported interfaces: %@", __func__, ifs); id info = nil; for (nsstring *ifnam in ifs) { info = (__bridge_transfer id)cncopycurrentnetworkinfo((__bridge cfstringref)ifnam); nslog(@"%@ => %@", ifnam, info); if (info && [info count]) { break; } } return info; }
以上就是ios 获取已连接的wifi信息的实例,如有疑问请留言或者到本站社区交流讨论,感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!