Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

`@discardableResult override init()` in Swift 3.1 throwing `warn_unused_result` Objective-C warning

I have a Swift class that is bridged to Objective-C. Even with @discardableResult, it's throwing this warning on build in the Objective-C class:

Ignoring return value of function declared with 'warn_unused_result' attribute

Is there a way to silence this? This is in Xcode 8.3 with Swift 3.1.

like image 801
Ben Guild Avatar asked Nov 08 '22 00:11

Ben Guild


1 Answers

A cast to (void) should silence the warning:

(void)[SingletonClass sharedInstance];
like image 195
weak Avatar answered Nov 15 '22 12:11

weak