. THIS is PLIST
NSString *post = [NSString stringWithFormat:@"email=%@&password=%@ & user_type=%@",_emailID.text,_password.text, user_type];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:@"my url"]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if(conn) {
NSLog(@"Connection Successful");
} else {
NSLog(@"Connection could not be made");
}
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data{
[self.receivedData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{
NSLog(@"%@" , error);
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection{
NSLog(@"Connected %@",connection);
}
I'm using this code in my Login form to POST data from email and password fields. i'm facing an error and not getting any response. Error is:
2017-05-01 10:58:06.236 PK.Estate[13412:4023436] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file. 2017-05-01 10:58:06.397 PK.Estate[13412:4022282] Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSUnderlyingError=0x608000253260 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSErrorFailingURLStringKey=url, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSErrorFailingURLKey=url}}, NSErrorFailingURLStringKey=url, NSErrorFailingURLKey=url, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}
email=%@&password=%@ & user_type=%@
should beemail=%@&password=%@&user_type=%@
there is space before user_type & after password – Fahim Parkar