Ich habe eine Lösung gefunden, müssen wir Credentials auf Benutzer-Schlüsselbund hinzuzufügen, hier ist mein Code
NSURLCredentialStorage * credentialStorage=[NSURLCredentialStorage sharedCredentialStorage]; //(1)
NSURLCredential * newCredential;
newCredential=[NSURLCredential credentialWithUser:@"myUserName" password:@"myPWD" persistence:NSURLCredentialPersistencePermanent]; //(2)
NSURLProtectionSpace * mySpaceHTTP=[[NSURLProtectionSpace alloc] initWithProxyHost:@"ipProxy" port:port type:NSURLProtectionSpaceHTTPProxy realm:nil authenticationMethod:nil]; //(3)
NSURLProtectionSpace * mySpaceHTTPS=[[NSURLProtectionSpace alloc] initWithProxyHost:@"ipProxy" port:port type:NSURLProtectionSpaceHTTPSProxy realm:nil authenticationMethod:nil]; //(4)
[credentialStorage setCredential:newCredential forProtectionSpace:mySpaceHTTP]; //(5)
[credentialStorage setCredential:newCredential forProtectionSpace:mySpaceHTTPS]; //(6)
Ich erholte mich zuerst die sharedCredentialStorage (1), dann erstellt ich neue NSURLCredential meinen Benutzernamen enthält, das Kennwort und die Art der Persistenz verwendet werden (2). Danach erstellt I zwei NSURLProtectionSpace (3) (4): ein für HTTPS Connexion und einen für HTTP Connexion
Und schließlich hinzugefügt i NSURLCredential die sharedCredentialStorage für diese ProtectionSpaces (5) (6)
Ich hoffe, dass dieser Code können Sie helfen