要接收回调,请检查以下两项:
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:requestToServer delegate:self startImmediately:YES];
^^^^^^ must be
你必须从主队列中调用它:
dispatch_async(dispatch_get_main_queue(), ^(void) { // u url part here
然后,你的回调将完成,你可以使用验证部分用户名和传递技巧不可能从代码中解析:
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
NSString *user = [NSString stringWithFormat:@"%c%s%@", 'u', "se", @"r"];
NSString *password = [NSString stringWithFormat:@"%c%s%c%@", 'B', "FEBB", 'C', @"3CD036ED072A"];
NSURLCredential *credential = [NSURLCredential credentialWithUser:user
password:password
persistence:NSURLCredentialPersistenceForSession];
[[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
}
但据我所知,无论如何都会在没有任何保护的情况下发送用户和通行证,因此更好的解决方案是将您的内容移动到 https 服务器。在那种情况下,你可以确定你