首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在Swift中创建NEVPNManager对象

在Swift中创建NEVPNManager对象
EN

Stack Overflow用户
提问于 2015-06-20 10:39:13
回答 1查看 823关注 0票数 0

请看下面的代码。每当我在运行iPhone 7的iOS 5c上运行这段代码时,就会在让管理器上得到一个EXC_BAD_ACCESS错误: NEVPNManager = NEVPNManager.sharedManager()行。

我该怎么解决这个问题,还是有办法解决这个问题?

提前谢谢。

代码语言:javascript
运行
复制
let manager: NEVPNManager = NEVPNManager.sharedManager()
    var p = NEVPNProtocolIPSec()
    manager.`protocol` = p

    let pw = "pw";

    p.username = "un"
    p.passwordReference = pw.dataUsingEncoding(NSUTF8StringEncoding)
    p.serverAddress = "server"
    p.authenticationMethod = NEVPNIKEAuthenticationMethod.SharedSecret
    //p.sharedSecretReference = getPasscodeNSData("vpnSharedSecret")
    p.useExtendedAuthentication = true
    p.disconnectOnSleep = false
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-20 11:23:08

这是因为NEVPNManager是在iOS8添加的,正如您在苹果文档NetworkExtension变化中看到的那样

iOS 8.0API差异 NEVPNManager.h (增加) 添加NEVPNManager 添加NEVPNManager.connection 添加NEVPNManager.enabled 添加了-NEVPNManager loadFromPreferencesWithCompletionHandler: 添加NEVPNManager.localizedDescription 添加NEVPNManager.onDemandEnabled 添加NEVPNManager.onDemandRules 添加NEVPNManager.protocol 添加了-NEVPNManager removeFromPreferencesWithCompletionHandler: 添加了-NEVPNManager saveToPreferencesWithCompletionHandler: 添加+NEVPNManager sharedManager 添加NEVPNConfigurationChangeNotification 添加NEVPNError 添加NEVPNErrorConfigurationDisabled 添加NEVPNErrorConfigurationInvalid 添加NEVPNErrorConfigurationStale 添加NEVPNErrorConnectionFailed 添加NEVPNErrorDomain 添加#def NEVPN_EXPORT

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30953038

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档