I've got Swift enum like this:
@objc public enum Status: Int {
case unknown;
case ok;
case failed;
}
It's properly bridged to Objective-C, and I can use it as, say StatusUnknown in Objective-C.
Now I have a function with callback:
+ (void)fetch:(void (^_Nonnull)(BOOL success))completion
And all I want is to replace BOOL with my Status enum. How to do that?
Clearly not like this:
+ (void)fetch:(void (^_Nonnull)(Status success))completion // Error: Unknown type name
I could use NSInteger like this:
+ (void)fetch:(void (^_Nonnull)(NSInteger success))completion
but then it's not really limiting values to Status enum.
So what is the best way to convey enum here?
Note:
- I simplified question, in reality enum is not called status and has many more values.
- Signature of the function has to match previous signature, but with different argument