Getting data synchronously from an asynchronous NSURLConnection

401 Views Asked by At

I'm trying to write a method that will operate like this:

NSString *responseData = [myAwesomeWrapper getStringfromURL:@"http://spam.com"];

Behind the scenes, I want to do the request asynchronously (because I need authentication and HTTPS). The problem is obviously that asynchronous requests require delegate callbacks using didReceiveResponse. That prevents me from writing the tidy method I have in mind.

While I understand this approach, I'm sick of the complicating factor it's creating when I need to make several different requests and access the data directly from the same controller. Inventing ways to capture the data without conflicting with existing calls is growing old.

I've read about possibly using NSNotificationCenter to imitate this, but the examples I've read don't reveal an obvious way to make this work.

Is my C# brain asking for too much?

Full disclosure: I'm really new at Objective-C/Cocoa-Touch. Go easy on me. :)

1

There are 1 best solutions below

5
On BEST ANSWER

Sounds like a job for ASIHTTPRequest