Use NSURL methods instead of CFURL functions #743

Merged
merged 2 commits into from Jan 21, 2013

Projects

None yet

3 participants

@0xced
  • Replace CFURLCopyUserName with -[NSURL user]
  • Replace CFURLCopyPassword with -[NSURL password]
0xced added some commits Jan 18, 2013
@0xced 0xced Use NSURL methods instead of CFURL functions
* Replace CFURLCopyUserName with -[NSURL user]
* Replace CFURLCopyPassword with -[NSURL password]
74346ad
@0xced 0xced Rename the `username` variable to `user` 7abc978
@PanamaDonne

Hi,
Did the changes but still get the same error.

if ([challenge previousFailureCount] == 0) {
NSURLCredential *credential = nil;

        NSString *user = [[self.request URL] user];
        NSString *password = [[self.request URL] password];

        if (user && password) {
            credential = [NSURLCredential credentialWithUser:user password:password persistence:NSURLCredentialPersistenceNone];
        } else if (user) {
            credential = [[[NSURLCredentialStorage sharedCredentialStorage] credentialsForProtectionSpace:[challenge protectionSpace]] objectForKey:user];
        } else {
            credential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:[challenge protectionSpace]];
        }

This commit is not supposed to fix anything. It is just for improving code readability because

NSString *password = [[self.request URL] password];

is easier to read than

NSString *password = (__bridge_transfer NSString *)CFURLCopyPassword((__bridge CFURLRef)[self.request URL]);

Ok, understand

@PanamaDonne
@mattt

Haha, I was starting to wonder how long that code would last in there. Textbook case of cargo culling from a chunk of code I saw somewhere else doing something like this. Thanks for sending that, dude :)

@mattt mattt closed this Jan 21, 2013
@mattt mattt reopened this Jan 21, 2013
@mattt mattt merged commit ba9185d into AFNetworking:master Jan 21, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment