diff --git a/Classes/lib/Connection.m b/Classes/lib/Connection.m index b881e79..ca3128a 100644 --- a/Classes/lib/Connection.m +++ b/Classes/lib/Connection.m @@ -68,14 +68,13 @@ + (Response *)sendRequest:(NSMutableURLRequest *)request withUser:(NSString *)us NSURLConnection *connection = [[[NSURLConnection alloc] initWithRequest:request delegate:connectionDelegate startImmediately:NO] autorelease]; connectionDelegate.connection = connection; - NSRunLoop* runLoop = [NSRunLoop mainRunLoop]; - //This needs to run in the main run loop in the default mode - [connection unscheduleFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - [connection scheduleInRunLoop:runLoop forMode:NSDefaultRunLoopMode]; + //use a custom runloop + static NSString *runLoopMode = @"com.yfactorial.objectiveresource.connectionLoop"; + [connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:runLoopMode]; [connection start]; while (![connectionDelegate isDone]) { - [runLoop runUntilDate:[NSDate dateWithTimeIntervalSinceNow:.3]]; + [[NSRunLoop currentRunLoop] runMode:runLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:.3]]; } Response *resp = [Response responseFrom:(NSHTTPURLResponse *)connectionDelegate.response withBody:connectionDelegate.data