Two part question
Part one: I am trying to create an ASynchronous request to my database. I am currently doing it Synchronously however I want to le
I have been working on a similar problem, I posted this question and got a clear answer here, I hope that helps with Part 2.
For part 1 what the others mentioned here are good but you need to add another check (I have modified an answer below). It is possible that your request will return say a 404 Error (page not found) in which case you will not get and error and data will be > 0. The 200 is a good response, you could also check the StatusCode for 404 or whatever.
[NSURLConnection
sendAsynchronousRequest:urlRequest
queue:[[NSOperationQueue alloc] init]
completionHandler:^(NSURLResponse *response,
NSData *data,
NSError *error)
{
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
if ([data length] >0 && error == nil && [httpResponse statusCode] == 200)
{
// DO YOUR WORK HERE
}