Class is written in Swift,
@objc class Test: NSObject {
@objc func testBoolean() -> Bool {
return true
}
@objc func testOptionalBoolean() -> Bool? {
return true
}
@objc func testThrowableBoolean() throws -> Bool {
return true
}
@objc func testThrowableOptionalBoolean() throws -> Bool? {
return true
}
}
Among these functions only first function is compilable.
Other functions compiler errors,
testOptionalBoolean: Method cannot be marked @objc because its result type cannot be represented in Objective-C
testThrowableBoolean: Throwing method cannot be marked @objc because it returns a value of type 'Bool'; return 'Void' or a type that bridges to an Objective-C class
testThrowableOptionalBoolean: Method cannot be marked @objc because its result type cannot be represented in Objective-C
What is the proper way to make all of functions available for objc callers?
@objc func testOptionalBoolean() -> NSNumber? { return testOptionalBoolean().map(NSNumber.init(value:)) }
But I know that some people doesn't like having two methods with the same name and parameters. - SweeperNSNumber
where compiler complains - Cy-4AH