First off, I know similar questions have been asked before and I've tried following the advice of this stackoverflow answer here to no avail. I also tried adding the basic gist of this as a comment, but I don't have enough rep yet :( Basically I am trying to use PFSubclassing to extend Parse's PFUser model. As such, here's my corresponding code:
User.swift:
import Foundation
import CoreLocation
class User : PFUser, PFSubclassing {
override init() {
super.init()
}
convenience init(email: String!) {
self.init()
self.email = email
self.username = email
}
// don't need to call User.registerSubclass() in AppDelegate because this
// is handling that here
override class func load() {
self.registerSubclass()
}
// Commented out because this is extending PFUser
// override class func parseClassName() -> String! {
// return "PFUser"
// }
}
Result on Tests:
-[PFObject _loadSensitiveUserDataFromKeychainItemWithName:]: unrecognized selector sent to instance 0x7f98ebc1c250
I'm also doing the following in my Bridging-Header:
#import <Parse/Parse.h>
#import <Parse/PFObject+Subclass.h>
If I un-comment "parseClassname() in User.swift" I get:
failed: caught "NSInvalidArgumentException", "Cannot initialize a PFUser with a custom class name."
Which leads me to believe that setting up the interfaces is at least partially working.
Based on all of the advice I've seen, I can't seem to figure out what I'm doing wrong. There is also an open bug that produces the same error message, but it is caused by using Parse's local data store and I haven't configured any of that.
At this point I feel like I am missing something dead obvious, or I am being affected by the same bug as mentioned above. Any suggestions?
Okay, solved my own problem here through trial and error. Essentially it looks like a cached logged in PFUser was causing problems. When Parse would initially load it was loading the logged in state from the emulator which was conflicting with the newly registered User subclass.
To fix this you can either:
PFUser.logOut()
right after Parse.setApplicationId() in AppDelegate to flush the cached user.Hopefully this helps someone else out in the future!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With