alternative to NSURLConnection sendSynchronousRequest
alternative to NSURLConnection sendSynchronousRequest
- Subject: alternative to NSURLConnection sendSynchronousRequest
- From: JB <email@hidden>
- Date: Tue, 13 Jan 2009 13:27:40 -0800
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 (email@hidden)
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:
This email sent to email@hidden