Created
July 26, 2016 19:09
-
-
Save hramos/feb1cfc437f4da2c785b716d3a8f16be to your computer and use it in GitHub Desktop.
Subclassing PFObject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface Armor : PFObject<PFSubclassing> | |
+ (NSString *)parseClassName; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import this header to let Armor know that PFObject privately provides most | |
// of the methods for PFSubclassing. | |
#import <Parse/PFObject+Subclass.h> | |
@implementation Armor | |
+ (void)load { | |
[self registerSubclass]; | |
} | |
+ (NSString *)parseClassName { | |
return @"Armor"; | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Armor : PFObject, PFSubclassing { | |
override class func initialize() { | |
struct Static { | |
static var onceToken : dispatch_once_t = 0; | |
} | |
dispatch_once(&Static.onceToken) { | |
self.registerSubclass() | |
} | |
} | |
static func parseClassName() -> String { | |
return "Armor" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import this header into your Swift bridge header file to | |
// let Armor know that PFObject privately provides most of | |
// the methods for PFSubclassing. | |
#import <Parse/PFObject+Subclass.h> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I try to subclass with Swift 4 I get "Method 'initialize()' defines Objective-C class method 'initialize', which is not permitted by Swift"