答案 0 :(得分:2)
我在iPhone项目中使用ASIHTTPRequest与Web应用程序进行通信。对于http身份验证,他们有一个方便的ASIAuthenticationDialog类来处理它。基本用法如下:
// Specifying a username and password to use in the URL
NSURL *url = [NSURL URLWithString:@"http://username:password@allseeing-i.com/top_secret/"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
// Setting a username and password to use on the request
NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com/top_secret/"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setUsername:@"username"];
[request setPassword:@"password"];