I am using Parse and created a new colums in the User. I set the field to "Required", but now I can't create a user anymore.
Error i get:
Login failed: ParseError code=142 error=myCustomColumn is required
This is how I did it:
do {
let currentUser = try User.signup(username: "user", password: "password")
print("Login succes: \(currentUser)")
} catch {
print("Login failed: \(error)")
}
How can I set my custom field? It's already created in the struct. I just need to set the value.
I am using ParseSwift.
This can be done by using the instance version of signUp in the documentation. An example is shown in the playgrounds:
//: To add additional information when signing up a user,
//: you should create an instance of your user first.
var newUser = User(username: "parse", password: "aPassword*", email: "[email protected]")
//: Add any other additional information.
newUser.targetScore = .init(score: 40)
newUser.signup { result in
switch result {
case .success(let user):
guard let currentUser = User.current else {
assertionFailure("Error: current user not stored locally")
return
}
assert(currentUser.hasSameObjectId(as: user))
print("Successfully signed up as user: \(user)")
case .failure(let error):
print("Error logging in: \(error)")
}
}
Also, in my example above, I’m signing up asynchronously, which is most likely the way you want to signup. In your example, you are signing up synchronously, which can hold up the main queue and cause run-time warnings in Xcode