私はビューベースのアプリケーションを開発しています。ログインボタンをクリックすると、Webサーバーの値で入力された値をチェックし、valiまたはinvalid.Iそれは成功した私はいずれかがこれをしてくださいについての私を助けてvalues..canサーバとcomapreするためのコードの下で変更する必要が私の電話アプリケーションでWebサーバーの値でユーザー名とパスワードを検証する方法
<!DOCTYPE html PUbLIC" -//W3C//DTD XHTML 1.0 Strict....
何この方法で結果を取得しています実行され、このようにコードをwriitenています。..
-(IBAction)buttonClick:(id)sender
{
NSString* username = nameInput.text;
NSString* pass = passInput.text;
if([nameInput.text isEqualToString:@"" ]|| [passInput.text isEqualToString:@""])
{
greeting.text = @"Input Your Value";
[nameInput resignFirstResponder];
[passInput resignFirstResponder];
return;
}
NSString *post =
[[NSString alloc] initWithFormat:@"uname=%@&pwd=%@",username,pass];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSURL *url = [NSURL URLWithString:@"https://108.16.210.28/Account/LogOn"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPMethod:@"POST"];
[theRequest setValue:postLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPBody:postData];
[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection)
{
webData = [[NSMutableData data] retain];
}
else
{
}
[nameInput resignFirstResponder];
[passInput resignFirstResponder];
nameInput.text = nil;
passInput.text = nil;
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
[connection release];
[webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSString *loginStatus = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
NSLog(loginStatus);
greeting.text = loginStatus;
[loginStatus release];
[connection release];
[webData release];
}
- (void)dealloc {
[super dealloc];
}
@end
私たちはあなたのコードをデバッグするためではありません。具体的に何が働いていないのですか?何を試しましたか? –
コードは正常に動作していますが、コードに基づいてWebサーバーに接続できる必要があります。サーバー値が入力値と一致する場合は無効なメッセージが表示されるはずですが、HTMLコード – Haritha