diff --git a/Classes/lib/Connection.m b/Classes/lib/Connection.m index b881e79..5221c0e 100644 --- a/Classes/lib/Connection.m +++ b/Classes/lib/Connection.m @@ -72,11 +72,9 @@ + (Response *)sendRequest:(NSMutableURLRequest *)request withUser:(NSString *)us //This needs to run in the main run loop in the default mode [connection unscheduleFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - [connection scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode]; + [connection scheduleInRunLoop:runLoop forMode:NSConnectionReplyMode]; [connection start]; - while (![connectionDelegate isDone]) { - [runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:.3]]; - } + while (![connectionDelegate isDone] && [runLoop runMode:NSConnectionReplyMode beforeDate:[NSDate distantFuture]]); Response *resp = [Response responseFrom:(NSHTTPURLResponse *)connectionDelegate.response withBody:connectionDelegate.data andError:connectionDelegate.error];