I have this enum in Swift SDK, and need to print the description
as a debug message.
@objc public enum ResultCode : UInt16 {
case noError = 0x0000
@objc public func description() -> String {
switch self {
case .noError:
return "No Error"
}
}
}
The description
can not be called in Objc like this:
[taskManager.sendRequest requestWithCompletion:^(ResultCode resultCode) {
NSString *resultCodeDescription = [resultCode description];//Bad receiver type 'ResultCode' (aka 'enum ResultCode')
NSLog(@"Result code description: %@", resultCodeDescription);
}];
I know that adding a ResultCode extension in Swift file and a @objc
function is a solution, but I prefer to solve this in objc file, how can I approach this?