Result of call is unused
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
}
Swift result of call to is unused
Assign the return value of the function to _
to explicitly discard it, like this:
_ = somethingThatReturnsAValueYouDontCareAbout()
Swift 3 warns about unused function return values, so you need to show it that you know what you're doing.
Swift 3 : Warning Unused result of call when overriding BecomeFirstResponder
The bug has been solved in the lastest Swift version.
Swift Compiler Warning : Result of call to 'save(defaults:)' is unused
The DataHandling
instance's save(defaults:)
function technically returns a value, even if you don't use it. To silence this warning, assign it to _
to signify that you don't intend to use the result value, e.g.:
_ = ordering.save(defaults: indexPath.defaultsKey)
or
let _ = ordering.save(defaults: indexPath.defaultsKey)
Just to be clear, this is almost definitely not why your tableview is not loading data. It should be pretty insignificant. The indexPath.defaultsKey
is being saved (assuming the API works).
Swift 3 Result of call to (_:parameters:completionHandler:)' is unused warning and Braced block of statements is an unused closure error
You can annotate the method it is warning you about with @discardableResult
.
For example:
@discardableResult
func foobar() -> Bool {
return true
}
Result of call to 'sorted(by:)' is unused
.sorted(by: )
returns the sorted array, if you need the sorted array and leave the original array untouched.
.sort(by:)
it doesn't returns anything, it sorts the original array.
If you don't care about original array being modified, then use .sort(by:)
Result of call to [myFunction] is unused
This is behaviour that has been introduced in Swift 3. Instead of having to explicitly annotate functions with @warn_unused_result
in order to tell the compiler that the result should be used by the caller, this is now the default behaviour.
You can use the @discardableResult
attribute on your function in order to inform the compiler that the return value doesn't have to be 'consumed' by the caller.
@discardableResult
func makeConstraint(withAnotherView : UIView) -> NSLayoutConstraint {
... // do things that have side effects
return NSLayoutConstraint()
}
view1.makeConstraint(view2) // No warning
let constraint = view1.makeConstraint(view2) // Works as expected
You can read about this change in more detail on the evolution proposal.
Related Topics
Invalid Signature (Invalid Binary) on Itunes Connect
Determine User's "Temperature Unit" Setting on iOS 10 (Celsius/Fahrenheit)
Pod Install Command with Error
Urlresponse Is Not Retrieved After Storing in Cache Using Storecachedresponse
Swift: Failed to Assign Value to a Property of Protocol
Get Error Code -11843 While Exporting Mp3 File in Ipod Library Since iOS 5.1
How to Detect iOS 6 and All Minor Versions by User Agent
How to Share Nsdata or Phasset Video Using Facebook iOS Sdk 4.0 Fbsdksharedialog
How to Display the Emoji and Special Characters in Uilabel and Uitextviews
How to Save Created PDF in Document Folder and Merge in iOS
How to Handle "Cfnetwork Sslhandshake Failed" in iOS
Detect Touch on Child Node of Object in Spritekit
What Do the "M" and "A" Icons in the Project Navigator of Xcode 4 Mean When I Create a New Project
Autolayout Views Make App Crash on Popviewcontroller
Swift JSON Error:Could Not Cast Value of Type '_Nsdictionarym' to 'Nsarray'
How to Pass Information Between Storyboard Segues
Storyboard Is Not Showing Custom Color Hex Code in Xcode 12.0.1