ios-nd-networking
ios-nd-networking copied to clipboard
Silence warnings for unused return type in taskForGETRequest.
After making the change to cancel the search task, you probably noticed some annoying warnings like this.
Result of call to 'taskForGETRequest(url:responseType:completion:)' is unused
Ever since we added the return type, Xcode now shows warnings every time we call it without assigning something to the URLSessionDataTask
it returns. But for the most part, we don't actually need to access the returned task.
A quick fix, is to add the @discardableResult
annotation before the declaration of the taskForGETRequest
function (this is an annotation just like adding @escaping
before a closure). Doing so will silence the warnings.
@discardableResult class func taskForGETRequest<ResponseType: Decodable>(url: URL, responseType: ResponseType.Type, completion: @escaping (ResponseType?, Error?) -> Void) -> URLSessionDataTask {