PFUser class must be registered with registerSubclass before using Parse
I am using Parse 1.7.5 and Swift 1.2 to create an account based app. I have created a class User
in which I have a property called by the user of the type PFUser
. The goal here is to implement all the Parse logic in this class so that in the future, if necessary, I can easily change the backend without changing the logic in the rest of my application.
When I try to run the application, I get the following error in the console: The PFUser class must be registered with registerSubclass before using Parse.
I don't understand why I am getting this message as I am not subclassing the PFUser class.
Here is the source code for the class User
:
import Foundation import Parse class User { var user: PFUser = PFUser() var location: PFGeoPoint? var timeLeft: Int? var error: NSError? // MARK: INIT init() { if let user = PFUser.currentUser() { self.user = user } } convenience init(username: String, password: String, email: String, firstName: String, lastName: String) { self.init() user.username = username user.password = password user.email = email user["firstName"] = firstName user["lastName"] = lastName } // MARK: USER INFO func getUserLocation() { PFGeoPoint.geoPointForCurrentLocationInBackground { (geoPoint: PFGeoPoint?, error: NSError?) -> Void in if let error = error { self.error = error } else { self.location = geoPoint } } } // MARK: LOGIN SIGNUP func loginWithUsername(username: String, password: String) -> Bool { PFUser.logInWithUsernameInBackground(username, password: password, block: { user, error in if let error = error { self.error = error print("\(error)") } }) return isLoggedIn() } func logout() { PFUser.logOut() } func isLoggedIn() -> Bool { return user.isAuthenticated() } }
Thank you for your help.
source to share
No one has answered this question yet
Check out similar questions: