Below is how I declared enum
in Swift. I have a property of this enum
type in one class. But I am not able to access this property from Objective-C. Is there any workaround for this? I wrote my app completely on Swift. I am now integrating the thirdparty SDK which is completely on Objective-C. I need the value of this enum
property in Objective-C.
@objc public enum PaymentType: NSInteger {
case COD
case NB
case CARDS
case PAYTM
case CITRUS
}
var modeOfPayment: PaymentType?
When I'm trying to access this property in Objective-C, it says
property modeOfPayment not found
NSLog(@"%d",[Helper sharedInstance].order.modeOfPayment);
@objc public enum PaymentType: Int {
case none
case COD
case NB
case CARDS
case PAYTM
case CITRUS
}
var modeOfPayment: PaymentType = .none
Make sure that you have case none in the Swift enum and assigned .none
to property
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.