0

How can I make a synchronous request using the AFNetworking library. I've tried this link

https://github.com/paulmelnikow/AFNetworking-Synchronous/blob/master/AFHTTPClient%2BSynchronous.m

But it seems it isn't reliable. Sometime the request runs async using this approach.

Thanks in advance for your help.

H.

EDIT:

I've a bunch of operations that fetch data from the server, each operation fetches the data synchronously since the operation itself is already in background. How can I do this using AFNetworking?

Maystro
  • 2,907
  • 8
  • 36
  • 71
  • Why do you want to have a synchronous request? They block the main thread and often are not the best solution. – jbouaziz Feb 07 '14 at 15:45
  • Actually, I've already operations running in background. They are fetching data from the server so I need them to fetch the data synchronously. – Maystro Feb 07 '14 at 15:47
  • @trojanfoe, I've already tested what they mentioned in the URL you proposed. It didn't work – Maystro Feb 07 '14 at 15:53
  • If I'm working on the main thread I know I should not do networking synchronously. In my case, I'm working on background threads and each thread has to fetch some data from the server. That's why I need to do it synchronously(I'm not working on the main thread so no need to do the job asynchronously). As I understood, there is no nothing in AFNetworking can do my job right? – Maystro Feb 08 '14 at 11:02
  • That could help http://stackoverflow.com/a/7970037/1835155. – jbouaziz Feb 08 '14 at 15:38
  • Actually nop, I've already tried it and it didn't work without knowing why!!! Finally, I could make it working properly using the link I've shared in the question. – Maystro Feb 08 '14 at 15:50

0 Answers0