沒有使用返回值時, 警告swift
swift:code
@warn_unused_result func doSomething() -> Bool { return true }
OC:blog
- (BOOL)doSomething __attribute__((warn_unused_result)) { return YES; }
沒有使用返回值時, 不警告it
swift:io
@discardableResult func doSomething() -> Bool { return true }
OC:event
To prevent the compiler from flooding us with warnings when importing Objective-C code the @discardableResult attribute is automatically added for all non-void functions that are not marked with the ((warn_unused_result)) attribute.function