如何在Swift中优胜美地之后获取当前的wifi网络名称? [英] How do I get the current wifi network name after Yosemite in Swift?

查看:165
本文介绍了如何在Swift中优胜美地之后获取当前的wifi网络名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Mavericks中,我正在使用[CWInterface interface]来获取当前连接的网络.具有因优胜美地而被弃用.

In Mavericks I was using [CWInterface interface] to grab the currently connected network. That has been deprecated for Yosemite.

与往常一样,Apple文档未提供有关此主题的指导.

As usual Apple documentation provides no guidance on this topic.

那么如何用Swift在约塞米蒂获得当前连接的Wifi网络名称?

So how can I get the currently connected Wifi network name in Yosemite with Swift?

推荐答案

所以我知道了.如果将nil传递给interfaceName,它将为您提供当前连接的wifi网络.然后,您可以呼叫ssid()以获得网络的名称.

So I figured it out. If you pass nil to the interfaceName, it will give you the currently connected wifi network. You can then call ssid() to get the name of the network.

就像这样:CWInterface(interfaceName: nil).ssid()

这篇关于如何在Swift中优胜美地之后获取当前的wifi网络名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆