Php 使用xcode登录后

Php 使用xcode登录后,php,xcode,post,login,Php,Xcode,Post,Login,我想更改代码,使用户在使用应用程序时自动登录。 目前我的代码是: NSString *identifiant = [[NSUserDefaults standardUserDefaults] valueForKey:@"Identifiant"]; NSString *password = [[NSUserDefaults standardUserDefaults] valueForKey:@"Password"]; if((identifiant) && (password))

我想更改代码,使用户在使用应用程序时自动登录。 目前我的代码是:

NSString *identifiant = [[NSUserDefaults standardUserDefaults] valueForKey:@"Identifiant"];
NSString *password = [[NSUserDefaults standardUserDefaults] valueForKey:@"Password"];
if((identifiant) && (password))
{
    //Configure URL
    NSString* host = @"http://www.example.com";
    NSString* complement = @"/account/login";



    NSString* user_name = [[NSUserDefaults standardUserDefaults] valueForKey:@"Identifiant"];
    NSString* password = [[NSUserDefaults standardUserDefaults] valueForKey:@"Password"];
    //Add URL + Folder
    NSString *urlString = [NSString stringWithFormat:@"%@%@", host, complement];


    //NSURL *url = [NSURL URLWithString:urlString];
    NSURL *url = [NSURL URLWithString:urlString];


    //NSURLRequest *request = [NSURLRequest requestWithURL:url];

    //Add some informations POST
    NSString *post = [NSString stringWithFormat:@"user_name=%@&password=%@&submit=submit", user_name, password];;


    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

    NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:postData];


    NSOperationQueue *queue = [[NSOperationQueue alloc] init];



    [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
     {
         if ([data length] > 0 && error == nil) [_loadscreen loadRequest:request];
         else if (error != nil) NSLog(@"Error: %@", error);
     }];
}
else
{


UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"login"];
[self presentViewController:controller animated:YES completion:nil];
}
这段代码可以使用,但当用户未连接或其ID不正确时,我没有错误消息。 我们是否可以使用post connexion更新此代码,更改为更好的代码,因为在我的php系统中,我检查post是否已提交