Result of call is unused

前端 未结 2 1265
再見小時候
再見小時候 2021-01-21 03:39

Right below the second comment, I receive an error of \"Result of call to \'taskForDeleteMethod\' is unused. Why is this when I use the results and error in the closure followin

2条回答
  •  独厮守ぢ
    2021-01-21 03:46

    You are confusing the results variable, which is, indeed, used inside the closure, and the result of the taskForDELETEMethod call itself, which is NSURLSessionDataTask object.

    From the examples of using taskForDELETEMethod that I was able to find online it looks like it is perfectly OK to ignore the return value, so you can avoid this warning by assigning the result to _ variable, i.e.

    let _ = taskForDELETEMethod {
        ... // The rest of your code goes here
    }
    

提交回复
热议问题