                 error: error
             )
             
-            dispatch_semaphore_signal(semaphore)
-        })
+            semaphore.signal()
+        }
         
-        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER)
+        _ = semaphore.wait(timeout: DispatchTime.distantFuture)
         
         return result
     }

     
     - returns: The response.
     */
    @warn_unused_result public func responseData() -> Response<NSData, NSError> {
        
        let semaphore = dispatch_semaphore_create(0)
        
        var result: Response<NSData, NSError>!
        
        self.responseData(queue: dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), completionHandler: { response in
            
            result = response
            dispatch_semaphore_signal(semaphore)
            
        })
        
        dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER)
        
        return result
    }

     
     - returns: The response.
     */
    public func responseString(encoding: String.Encoding? = nil) -> DataResponse<String> {
        
        let semaphore = DispatchSemaphore(value: 0)
        
        var result: DataResponse<String>!
        self.responseString(queue: DispatchQueue.global(qos: .default), encoding: encoding){ response in
            
            result = response
            semaphore.signal()
            
        }
        
        _ = semaphore.wait(timeout: DispatchTime.distantFuture)
        
        return result
    }
