Enum de estructuras en Swift 3.0
Estoy tratando de crear una enumeración de una estructura que me gustaría inicializar:
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
}
}
}
Recibo los siguientes errores:
Tipo AllStructs no se ajusta al protocolo 'RawRepresentable'
Supongo que las enumeraciones no se pueden usar de esta manera. Debemos usar primitivas.