iphone - 当 ASI Http Request 上的用户名或密码验证错误时,如何设置警报?
<p><p>对我来说,我已经完成了 asi http 请求。但是当我在登录页面上调用此方法时。如何为错误登录设置身份验证警报 View ,下面是 ASI HTTP 请求的方法</p>
<pre><code>-(void) authenticate:(NSString*) uname password:(NSString*) pwd{
NSString *format = @"%s %d";
NSLog(format, __FUNCTION__);
myAppDelegate *appDelegate = (myAppDelegate *) [delegate];
appDelegate.HUD.progress = 0.1f;
appDelegate.HUD.labelText =@"Authenticating...";
NSURL *url = ];
ASIHTTPRequest *request = ;
request.shouldPresentCredentialsBeforeChallenge = YES;
;
;
request.userInfo = ;
;
;}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><pre><code>- (IBAction)login_btn:(id)sender {
// secondview *second=[initWithNibName:@"secondview" bundle:nil];
// ;
// ;
/*
triangletechniqa.com/projects/funny/webservic/login.php?username=admin&password=123
*/
NSString *post =;
NSData *postData = ;
NSString *postLength = ];
NSMutableURLRequest *request = [[ init] autorelease];
];
;
;
;
;
NSError *error;
NSURLResponse *response;
NSData *urlData=;
NSString *str=[initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"%@",str);
// NSMutableArray *tempArr = ;
// NSLog(@"%@",tempArr);
if()
{
UIAlertView *unsucess=[initWithTitle:@"Sorrrrry" message:@"Incurrect username and password" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
;
;
}
else
{
UIAlertView *success = [[initWithTitle:@"successful" message:@"angry"
delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil] autorelease];
;
secondview *view=[initWithNibName:@"secondview" bundle:nil];
;
;
}
}
</code></pre></p>
<p style="font-size: 20px;">关于iphone - 当 ASI Http Request 上的用户名或密码验证错误时,如何设置警报?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/13577990/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/13577990/
</a>
</p>
页:
[1]