Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence warnings for unused return type in taskForGETRequest. #7

Open
OwenLaRosa opened this issue Nov 9, 2018 · 1 comment
Open
Labels
moviemanagerchallenge Task for "Improve the Movie Manager" Challenge

Comments

@OwenLaRosa
Copy link
Contributor

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.

@OwenLaRosa OwenLaRosa added the moviemanagerchallenge Task for "Improve the Movie Manager" Challenge label Nov 9, 2018
@ssvedin
Copy link

ssvedin commented Mar 22, 2019

@discardableResult class func taskForGETRequest<ResponseType: Decodable>(url: URL, responseType: ResponseType.Type, completion: @escaping (ResponseType?, Error?) -> Void) -> URLSessionDataTask {

AsmaHero added a commit to AsmaHero/ios-nd-networking that referenced this issue Jun 5, 2019
Silence warnings for unused return type in taskForGETRequest.
nihalerdal added a commit to nihalerdal/TheMovieManager that referenced this issue May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
moviemanagerchallenge Task for "Improve the Movie Manager" Challenge
Projects
None yet
Development

No branches or pull requests

2 participants