Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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
Objective c ASIHTTPRequest setDomain->NSURLRequest等效项?_Objective C_Nsurlconnection_Asihttprequest_Nsmutableurlrequest - Fatal编程技术网

Objective c ASIHTTPRequest setDomain->NSURLRequest等效项?

Objective c ASIHTTPRequest setDomain->NSURLRequest等效项?,objective-c,nsurlconnection,asihttprequest,nsmutableurlrequest,Objective C,Nsurlconnection,Asihttprequest,Nsmutableurlrequest,我正在尝试将一些严重依赖ASIHTTPRequest库的SOAP请求的旧代码转换为使用标准NSMutableURLRequest。然而,我遇到了一个问题:虽然使用AsiTpRequest我可以访问setDomain函数,但似乎找不到与NSMutableURLRequest等效的函数 有人知道是否有一个等价的函数吗?我尝试将其设置为名为Domain的标题,但似乎不起作用。最终遵循了以下建议: 事实证明,您不必独立设置域;您可以通过将其作为用户名的一部分进行传递来进行设置,如下所示: 域\\用户名

我正在尝试将一些严重依赖ASIHTTPRequest库的SOAP请求的旧代码转换为使用标准NSMutableURLRequest。然而,我遇到了一个问题:虽然使用AsiTpRequest我可以访问setDomain函数,但似乎找不到与NSMutableURLRequest等效的函数


有人知道是否有一个等价的函数吗?我尝试将其设置为名为Domain的标题,但似乎不起作用。

最终遵循了以下建议:

事实证明,您不必独立设置域;您可以通过将其作为用户名的一部分进行传递来进行设置,如下所示: 域\\用户名 在NSURLCredentials对象中。我最终使用的确切代码是:

//takes care of HTTP Authentication
- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
    NSString* authMethod = [[challenge protectionSpace] authenticationMethod];

    if ([authMethod isEqualToString:NSURLAuthenticationMethodNTLM]) {
        NSURLCredential *credential = [NSURLCredential credentialWithUser:[NSString stringWithFormat:@"domain\\%@", self.userName]
                                                                 password:self.password
                                                              persistence:NSURLCredentialPersistenceForSession];
        [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge];
    }
}
当然,这都是假设类是一个NSURLConnectionElegate