Skip to content

Silence warnings for unused return type in taskForGETRequest. #7

@OwenLaRosa

Description

@OwenLaRosa

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    moviemanagerchallengeTask for "Improve the Movie Manager" Challenge

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions