我使用以下代码创建了网络管理器。但是一旦第一行呼叫运行,经理就为零,因此任何其他方法都不会受到影响。谁能让我知道我做错了什么?
NEVPNManager *manager = [NEVPNManager sharedManager];
NEVPNProtocolIPSec *p = [[NEVPNProtocolIPSec alloc] init];
p.username = @"MYUSERNAME";
p.passwordReference = [@"MYPW" dataUsingEncoding:NSUTF8StringEncoding];
p.serverAddress = @"[NetworkIP]";
p.authenticationMethod = NEVPNIKEAuthenticationMethodSharedSecret;
p.sharedSecretReference = [@"SharedSecretHashCode" dataUsingEncoding:NSUTF8StringEncoding];
[manager setProtocol:p];
[manager setOnDemandEnabled:NO];
[manager setLocalizedDescription:@"VIT VPN"];
NSArray *array = [NSArray new];
[manager setOnDemandRules: array];
NSLog(@"Connection desciption: %@", manager.localizedDescription);
NSLog(@"VPN status: %li", (long)manager.connection.status);
[manager saveToPreferencesWithCompletionHandler:^(NSError *error) {
if(error) {
NSLog(@"Save error: %@", error);
}
}];
" manager
" 是 nil 。请帮忙。提前致谢。