Hi all,

I'm building a client for a server with (apparently) weird redirect issues,
I cannot get a proper HTTP response using NSURLConnection
sendSynchronousRequest

However, I can print out the response code using the asynchronous method:
[[NSURLConnection alloc] initWithRequest:request delegate:self];

When I swap this method in, I can print out the status code just fine.
However, because this approach is asynchronous my code calls this method and
moves on without waiting for a return value.  I need the request to complete
before moving on.

How can I force my code to wait for the asynchronous request to finish,
without using sendSynchronousRequest?

example:

- (void)post{

  NSLog(@"building batch request");
  NSMutableURLRequest* request = [self requestWithMethod:POST];

  NSLog(@"posting batch request");
  // this method wraps NSURLConnection initWithRequest:request delegate:self
  [self sendAsynchronousRequest:request];

  // should not be evaluated until sendAsynchronousRequest is complete
  NSLog(@"post finished");
}

Many thanks!
JB
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to