swiftparse-platformpfsubclassing

Parse PFSubclassing not working with Swift


I have copied the Parse Swift example for Subclassing:

class Armor : PFObject, PFSubclassing {

    override class func load() {
        self.registerSubclass()
    }
    class func parseClassName() -> String! {
        return "Armor"
    }
}

I get the following errors:

/Parse/Armor.swift:11:1: error: type 'Armor' does not conform to protocol 'PFSubclassing'
class Armor : PFObject, PFSubclassing {
^
__ObjC.PFSubclassing:15:28: note: protocol requires function 'object()' with type '() -> Self!'
  @objc(object) class func object() -> Self!
                           ^
__ObjC.PFSubclassing:23:52: note: protocol requires function 'objectWithoutDataWithObjectId' with type '(String!) -> Self!'
  @objc(objectWithoutDataWithObjectId:) class func objectWithoutDataWithObjectId(objectId: String!) -> Self!
                                                   ^
__ObjC.PFSubclassing:30:27: note: protocol requires function 'query()' with type '() -> PFQuery!'
  @objc(query) class func query() -> PFQuery!
                          ^
__ObjC.PFSubclassing:35:38: note: protocol requires function 'registerSubclass()' with type '() -> Void'
  @objc(registerSubclass) class func registerSubclass()
                                     ^
/Parse/Armor.swift:14:9: error: 'Armor.Type' does not have a member named 'registerSubclass'
        self.registerSubclass()
        ^    ~~~~~~~~~~~~~~~~

I saw this answer: https://stackoverflow.com/a/24899411/843151 and tried that solution with no luck, I get the same errors.

Any suggestions of why this is happening? Thanks in advance.


Solution

  • I needed to import the parse PFObject+Subclass.h in my Objective-C bridging header

    #import <Parse/PFObject+Subclass.h>