Configure and manage ios8 VPN in Swift

I am trying to set up a VPN connection in an application using the configuration and management of iOS8 VPN, but I am stuck. I use the resources http://ramezanpour.net/post/2014/08/03/configure-and-manage-vpn-connections-programmatically-in-ios-8/ , but I am having problems associating the protocol with the VPN manager.

So far I have the following code, and in accordance with the above guide, you need to associate the protocol with the manager ...

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 

I tried writing manager.protocol = p, but I get the error "expected member name". and "expected identifier in the protocol declaration." I tried the setProtocol function, which is used in some Objective-C [manager setProtocol: p] 'examples, but this does not seem to exist in the latest xcode assembly.

Can anyone help? There is also almost no information about using VPN features on the Internet - even on the Apple website. Any pointers would be helpful.

Thanks,

Oliver.

+5
source share
1 answer
 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 . Backlinks 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

+2
source

Source: https://habr.com/ru/post/1204767/


All Articles