积极答复者
手机客户端认证登陆的问题

问题
答案
全部回复
-
谢谢您的回复。顺利通过验证了
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse*)response
{
NSLog(@"get the whole response");
[self.receivedData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
NSLog(@"get some data");
[self.receivedData appendData:data];
NSString *str = [[NSString alloc] initWithData:self.receivedData encoding:NSUTF8StringEncoding];
NSLog(str,@"");
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
[connection release];
}
-(void)connection:(NSURLConnection *)connection
didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge
*)challenge
{
NSString *name = @"name";
NSString *password = @"pwd";
if ([challenge previousFailureCount] == 0) {
NSURLCredential *newCredential;
newCredential=[NSURLCredential credentialWithUser:name
password:password
persistence:NSURLCredentialPersistenceForSession];
[[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
//[self showPreferencesCredentialsAreIncorrectPanel:self];
}
}
- 已编辑 zenghui 2011年11月18日 2:47