Cicero
11/21/2020, 9:13 PMdata class LoginModel(
@SerialName("username")
val username: String?,
@SerialName("password")
val password: String?,
@SerialName("userType")
val userType: String = "PROFESSIONAL"
)
With the serialisers and all, when I try to access it in swift I find this:
- (instancetype)initWithUsername:(NSString * _Nullable)username password:(NSString * _Nullable)password userType:(NSString *)userType
And when I try to use it on my code it kinda foces me to put something on my variable with a pre defined value, like this:
let login = common.LoginModel(username: emailTextfield.text, password: passwordTextField.text, userType: “PROFESSIONAL”)
I can live with this but I would like to know if there is an immediate solution.
PS: It works fine on android, as intended.
How default values work on swift: https://docs.swift.org/swift-book/LanguageGuide/Functions.htmlrusshwolf
11/21/2020, 10:05 PMdata class LoginModel(...) {
constructor(username: String, password: String) : this(username, password, "PROFESSIONAL")
}
Cicero
11/21/2020, 10:27 PMBig Chungus
11/21/2020, 10:39 PMrusshwolf
11/21/2020, 10:41 PM