Ignoring return value of function declared with "warn_unused_result" attribute
It should work to cast the expression to a void expression.
(void)[self.emailField becomeFirstResponder];
(Even I cannot reproduce the warning. However, this might depend on the warning flags.)
To your edit:
BOOL ignore = [self.emailField becomeFirstResponder];
Likely
BOOL ignore = [self.emailField becomeFirstResponder];
ignore = ignore;
// or
(void)ignore;
should remove the warning. (It does with my flags.) However, this an ugly hack, too.
BTW: There is a reason for the attribute. Maybe you should recheck, whether it is a good idea, not to test for the return value.
You could get this warning if you have a Swift function that you call from Objective-C code. You can silence it by adding @discardableResult
before the function in Swift, like this:
@objc @discardableResult func yourFanzyFuncInSwift(argument: String) -> Bool { ... }
Seems like warn_unused_result is the default setting in Swift, meaning that you shouldn't write code that ignores return values.