I'm trying to get a standard subclassing to work with swift.
Bridging-Header.h
#import <Parse/Parse.h>
#import <Parse/PFObject+Subclass.h>
#import <Parse/PFGeoPoint.h>
Subclass
class Event: PFObject, PFSubclassing {
class func parseClassName() -> String! {
return "Event"
}
override class func load() {
registerSubclass()
}
}
getting a compile error saying that Event does not conform to PFSubclassing.
Any suggestions?
Check out my Parse Subclass generator GSParseSchema. It can generate the Swift and Objective-C classes for you.
In Swift, you'll want to override the initialize function.
override class func initialize() {
struct Static {
static var onceToken : dispatch_once_t = 0;
}
dispatch_once(&Static.onceToken) {
self.registerSubclass()
}
}
I've found this auto-registration to not always work, so I also explicitly register the subclasses in my AppDelegate. Be sure you register you before you initialize Parse with setApplicationId:clientKey:
Event.registerSubclass()
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