I had build a project on Xcode 6.4 . It was working fine . But the day i have upgraded my Xcode to Xcode 7, all the JSON services are not working and always giving me error . Here is my code
NSDictionary *get = @{@"name":name.text,@"username":username.text,@"mobile":phonenumber.text};
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:get options:kNilOptions error:nil];
NSString *jsonInputString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSString *post = [[NSString alloc]initWithFormat:@"r=%@",jsonInputString];
NSURL *url=[NSURL URLWithString:[NSString stringWithFormat:@"%@",registerUrl]];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:120.0];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSError *error;
NSURLResponse *response;
NSData *responseData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
if (responseData != nil)
{
NSMutableDictionary *jsonDict = (NSMutableDictionary *)[NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error];
NSLog(@"Json Dictionary =======%@",jsonDict);
}
if (error)
{
NSLog(@"error %@",error.description);
}
It is still working fine on Xcode 6
Here is Error log
Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."