I am trying to create an enum of a struct that I would like to initialize:
struct CustomStruct {
var variable1: String
var variable2: AnyClass
var variable3: Int
init (variable1: String, variable2: AnyClass, variable3: Int) {
self.variable1 = variable1
self.variable2 = variable2
self.variable3 = variable3
}
}
enum AllStructs: CustomStruct {
case getData
case addNewData
func getAPI() -> CustomStruct {
switch self {
case getData:
return CustomStruct(variable1:"data1", variable2: SomeObject.class, variable3: POST)
case addNewData:
// Same to same
default:
return nil
}
}
}
I get the following errors:
Type AllStructs does not conform to protocol 'RawRepresentable'
I am assuming that enums cannot be used this way. We must use primitives.
apiUrl, norresponseType, norhttpType. Please first check the errors of your code in playground and then edit your question. Yourinitmethod also has twovariable3, I wanted to make an edit, but it's better you do it yourself so you know what you did wrong - mfaaniMNOX_MAPPINGSwhat are you trying to do in yourgetAPIfunc? - mfaani