So, hello people, I’m trying to do something that I expected to be rather simple and it’s not working.
I have this object:
data 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.html