请参阅下面的代码。每当我在运行iOS 7的iPhone 5c上运行此代码时,我在let管理器上收到一个EXC_BAD_ACCESS错误:NEVPNManager = NEVPNManager.sharedManager()行。
我如何解决这个问题,或者有办法解决这个问题?
提前致谢。
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
答案 0 :(得分:1)
这是因为在iOS8中添加了NEVPNManager,正如您在Apple文档NetworkExtension Changes中所看到的那样
iOS 8.0 API Diffs
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