ios - Swift中配置ios8 VPN配置和控制

标签 ios swift vpn

我正在尝试使用 ios8 的 VPN 配置和控制设置应用内 VPN 连接,但我被卡住了。我正在使用 http://ramezanpour.net/post/2014/08/03/configure-and-manage-vpn-connections-programmatically-in-ios-8/ 的资源帮助,但我在将协议(protocol)绑定(bind)到 VPN 管理器时遇到问题。

到目前为止,我有以下代码,然后按照上面的教程,您需要将协议(protocol)绑定(bind)到管理器...

func initVPN() {
    let manager: NEVPNManager = NEVPNManager.sharedManager()
    let p = NEVPNProtocolIPSec()

    p.username = "ospencer"
    p.passwordReference = getPasscodeNSData("vpnPassword")
    p.serverAddress = "vconnect.uk.capgemini.com"
    p.authenticationMethod = NEVPNIKEAuthenticationMethod.SharedSecret
    p.sharedSecretReference = getPasscodeNSData("vpnSharedSecret")
    p.useExtendedAuthentication = true
    p.disconnectOnSleep = false

我已经尝试编写 manager.protocol = p,但我收到错误“expected member name following .”和“协议(protocol)声明中的预期标识符”。我尝试了一些 Objective C 示例“[manager setProtocol:p]”中使用的 setProtocol 函数,但在最新的 xcode 构建中似乎不存在。

有人可以帮忙吗?此外,似乎几乎没有关于在互联网上使用 VPN 功能的详细信息 - 即使在 Apple 的网站上也是如此。任何指针都会有用。

谢谢,

奥利弗。

最佳答案

To use a reserved word as an identifier, put a backtick (`) before and after it. For example, class is not a valid identifier, but

class is valid. The backticks are not considered part of the identifier; x and x have the same meaning.

https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html

关于ios - Swift中配置ios8 VPN配置和控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26391231/

相关文章:

ios - 在 Cocoa 中解析 mailto URL 的现成解决方案?

ios - 如何使用iOS在parse.com上访问指针值的字段?

ios - 如何将我的 UILabel 与系统时间同步?

ios - Cell内的TableView动态高度问题

仅 VPN 网站上的 Java HTTP 请求

ios - 对与套接字相关的 iOS 内核 panic 进行分类

ios - GLKView 显示方法导致 [GLKView _createFramebuffer] 崩溃

ios - CA交易 : How to Cancel?

ios - 检查设备是否连接到 iOS 12 中的 VPN

azure - 无法从本地计算机 ping 到 azure vnet