Workaround for Swift2 which apparently fails to retain the completion blocks passed as parameters

This commit is contained in:
tifroz
2015-09-21 14:40:24 -07:00
parent 44c6a8adcf
commit 9d38bb4f94
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -759,7 +759,7 @@ static inline NSUInteger _ScanHexNumber(const void* bytes, NSUInteger size) {
- (void)processRequest:(GCDWebServerRequest*)request completion:(GCDWebServerCompletionBlock)completion { - (void)processRequest:(GCDWebServerRequest*)request completion:(GCDWebServerCompletionBlock)completion {
GWS_LOG_DEBUG(@"Connection on socket %i processing request \"%@ %@\" with %lu bytes body", _socket, _virtualHEAD ? @"HEAD" : _request.method, _request.path, (unsigned long)_bytesRead); GWS_LOG_DEBUG(@"Connection on socket %i processing request \"%@ %@\" with %lu bytes body", _socket, _virtualHEAD ? @"HEAD" : _request.method, _request.path, (unsigned long)_bytesRead);
@try { @try {
_handler.asyncProcessBlock(request, completion); _handler.asyncProcessBlock(request, [completion copy]);
} }
@catch (NSException* exception) { @catch (NSException* exception) {
GWS_LOG_EXCEPTION(exception); GWS_LOG_EXCEPTION(exception);
+1 -1
View File
@@ -242,7 +242,7 @@
- (void)performReadDataWithCompletion:(GCDWebServerBodyReaderCompletionBlock)block { - (void)performReadDataWithCompletion:(GCDWebServerBodyReaderCompletionBlock)block {
if ([_reader respondsToSelector:@selector(asyncReadDataWithCompletion:)]) { if ([_reader respondsToSelector:@selector(asyncReadDataWithCompletion:)]) {
[_reader asyncReadDataWithCompletion:block]; [_reader asyncReadDataWithCompletion:[block copy]];
} else { } else {
NSError* error = nil; NSError* error = nil;
NSData* data = [_reader readData:&error]; NSData* data = [_reader readData:&error];