, queue, , , , [NSOperationQueue mainQueue] ( ). queue , , , UI , .
, , , . .
[NSOperationQueue mainQueue] :
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
if (!data) {
NSLog(@"request failed: %@", error);
return;
}
if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
int statusCode = [(NSHTTPURLResponse *)response statusCode];
if (statusCode != 200) {
NSLog(@"request resulted in statusCode of %d", statusCode);
return;
}
}
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
if ([responseString rangeOfString:@"Welcome"].location != NSNotFound) {
loginPageStatusLabel.text = @"Correct";
NSLog(@"Correct Login");
[self performSegueWithIdentifier:@"toHome" sender:self];
} else {
loginPageStatusLabel.text = @"Incorrect";
NSLog(@"Login Failed");
}
}];