Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 尝试登录失败后,质询错误显示null_Ios_Ios7_Challenge Response - Fatal编程技术网

Ios 尝试登录失败后,质询错误显示null

Ios 尝试登录失败后,质询错误显示null,ios,ios7,challenge-response,Ios,Ios7,Challenge Response,这是iOS中REST/Webservice身份验证的一个现成示例 我的密码是错误的,我进入else条件的第二部分,这是正确的行为 但是[错误本地化描述]显示空值。我希望这里会显示一个错误。知道我错过了什么吗 我明白了: 无法验证:(null) 您的服务没有返回错误。请参见质询的课程描述,其中说明: 讨论如果协议不使用错误,此方法将返回nil 指示身份验证失败 我建议将日志记录为整个对象,如果描述是稀疏的,那么也可以记录其他属性 - (void)connection:(NSURLConnectio

这是iOS中REST/Webservice身份验证的一个现成示例

我的密码是错误的,我进入else条件的第二部分,这是正确的行为

但是
[错误本地化描述]
显示空值。我希望这里会显示一个错误。知道我错过了什么吗

我明白了:

无法验证:(null)


您的服务没有返回错误。请参见质询的课程描述,其中说明:

讨论如果协议不使用错误,此方法将返回nil 指示身份验证失败

我建议将日志记录为整个对象,如果描述是稀疏的,那么也可以记录其他属性

- (void)connection:(NSURLConnection *)conn didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
    if ([challenge previousFailureCount] == 0) {
        NSURLCredential *newCredential;

        newCredential = [NSURLCredential credentialWithUser:[FTKeychain loadValueForKey:IOS_USER_EMAIL]
                                                   password:[FTKeychain loadValueForKey:IOS_USER_PASSWORD]
                                                persistence:NSURLCredentialPersistenceNone];
        [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
    } else {
        [[challenge sender] cancelAuthenticationChallenge:challenge];

        // inform the user that the user name and password
        // in the preferences are incorrect
        // Why did I fail?
        NSError *error = [challenge error];
        NSLog(@"Can't authenticate: %@", [error localizedDescription]);
        // why is error localizedDescription null ?
    }
}