anyone try to solve this send synchronous Request problem...thanks in advance.
Asked
Active
Viewed 798 times
-2

Anbu.Karthik
- 82,064
- 23
- 174
- 143

Naveen Raj
- 1
- 2
-
Check the answer here: [http://stackoverflow.com/questions/32643207/ios9-sendsynchronousrequest-deprecated](http://stackoverflow.com/questions/32643207/ios9-sendsynchronousrequest-deprecated) – Ronak Chaniyara Feb 24 '16 at 10:24
-
Possible duplicate of [NSURLConnection deprecated in iOS9](http://stackoverflow.com/questions/32441229/nsurlconnection-deprecated-in-ios9) – Anbu.Karthik Feb 24 '16 at 10:31
-
1It's a duplicate + Do not post a screen shot of you code, rather copy/paste the relevant part of your code. – Larme Feb 24 '16 at 10:34
-
Consider to use asynchronous methods. They are more efficient than the workarounds to wait for completion. – vadian Feb 24 '16 at 10:34
2 Answers
0
NSUrlConnection Are depreciated In IOS 9 and +,So if you go for Sessions you will not get that Error.

Mahesh reddy
- 134
- 13
-
You are incorrect. Usage of `NSURLConnection` is discouraged, but it works perfectly. – Avi Feb 24 '16 at 11:26
-
@Avi It will work perfectly but i gave the answer regarding question,he is getting the depreciated error.please dont give negative marks – Mahesh reddy Feb 24 '16 at 11:29
-
-
0
Your actual problem is not NSURLConnection usage ios9 will handle it even if it is deprecated also, here the problem with HTTP request you are using from ios9 apple discourages the use of HTTP request as part of the App Transport Security (ATS).
You can bypass this by adding this key to your info.plist of the project
<key>App Transport Security Settings</key>
<dict>
<key>Allow Arbitrary Loads</key>
<YES/>
</dict>
Instead of sendSynchronousRequest: you can use following code.
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"response status code: %ld", (long)[httpResponse statusCode]);
if ([httpResponse statusCode] == 200) {
NSLog(@"Success");
} else
{
NSLog(@"Fail");
}
}] resume];

Vignesh Kumar
- 598
- 4
- 11
-
am new to this restful and iOS 9 ..i need to pass one userid like (1,2,3...) to my url then only it will give that details about the particular user..i attached App Transport Security(ATS) but now i did't get any response..thanks in advance – Naveen Raj Feb 25 '16 at 07:01
-
Can you give the sample URL? like : (http://localhost:4000/getUser?=123) is it crt? – Vignesh Kumar Feb 25 '16 at 09:20