我使用ASIHttprequest進行登錄認證Here is the deme codeASIHttprequest日誌中authenticaion
我努力的代碼是:
[self setRequest:[ASIHTTPRequest requestWithURL:url1]];
[_request setUseKeychainPersistence:[useKeychain isOn]];
[_request setDelegate:self];
[_request setShouldPresentAuthenticationDialog:[useBuiltInDialog isOn]];
[_request setDidFinishSelector:@selector(topSecretFetchComplete:)];
[_request setDidFailSelector:@selector(topSecretFetchFailed:)];
[_request startAsynchronous];
[request setValidatesSecureCertificate:NO];
[_request setValidatesSecureCertificate:NO];
請求失敗,請求完成方法
- (IBAction)topSecretFetchFailed:(ASIHTTPRequest *)theRequest{
[responseField setText:[[request error] localizedDescription]];
[responseField setFont:[UIFont boldSystemFontOfSize:12]];
}
- (IBAction)topSecretFetchComplete:(ASIHTTPRequest *)theRequest{
[responseField setText:[request responseString]];
[responseField setFont:[UIFont boldSystemFontOfSize:12]];
NSLog(@"Response :%@",[request responseString]);
}
- (void)authenticationNeededForRequest:(ASIHTTPRequest *)theRequest{
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Please Login" message:[request authenticationRealm] delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",nil];
[alertView addTextFieldWithValue:@"" label:@"Username"];
[alertView addTextFieldWithValue:@"" label:@"Password"];
[alertView show];
}
我是新來的iOS所以請......
在本演示中,當我去鍾一個警報是彈出但是當我使用我的web它給這樣
響應響應:ASIHTTPRequest:0xa846400
但不彈出alertview用於輸入用戶名和密碼
如果有任何其他更好的方式來驗證登錄請發uggest我
我希望將登錄爲rootview併成功登錄後,可以進入到App
感謝......當空格,特殊字符和換行字符是在
的NSLog(@ 「的迴應:%@」[TheReqest responseString])NOT的NSLog(@ 「迴應:%@」 ,theRequest); – Gabrail
ASIhttp是已停用的庫。使用[AFNetworking](https://github.com/AFNetworking/AFNetworking) –