Search code examples
propertiesswiftparse-platformsubclasspfuser

Subclass PFUser in swift


I wanna subclass the PFUser object in swift. I also want to declare my own variables. The Parse documentation on subclassing do not cover PFUser at this point.

Parse documentation on subclassing PFObject:

class Armor : PFObject, PFSubclassing {
    class func load() {
       self.registerSubclass()
    }
    class func parseClassName() -> String! {
       return "Armor"
    }
}

Solution

  • BridgingHeader.h:

    #import <Parse/Parse.h>
    #import <Parse/PFObject+Subclass.h>
    

    User.swift:

    import Foundation
    
    class User : PFUser, PFSubclassing {
    
    override class func load() {
        self.registerSubclass()
    }
    
    //My variables
    dynamic var firstname: String
    dynamic var lastname: String
    
    }
    

    DONT´T include this snippet when subclassing PFUser:

    class func parseClassName() -> String! {
        return "User"
    }