Έχω βρεθεί μια λύση, θα πρέπει να προσθέσετε διαπιστευτήρια στο μπρελόκ των χρηστών εδώ είναι ο κωδικός μου
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)
Θα ανακτηθεί πρώτα το sharedCredentialStorage (1), τότε θα δημιουργηθούν νέες NSURLCredential που περιέχει το όνομά μου χρήστη, τον κωδικό πρόσβασης και τον τύπο της εμμονής στη χρήση (2). Μετά από αυτό δημιούργησε δύο NSURLProtectionSpace (3) (4): μία για HTTPS Connexion, και ένα για HTTP Connexion
Και τέλος, θα προστεθεί NSURLCredential την sharedCredentialStorage για αυτές τις ProtectionSpaces (5) (6)
Ελπίζω ότι αυτός ο κώδικας μπορεί να σας βοηθήσει