Created
February 2, 2014 04:28
-
-
Save roothybrid7/8763072 to your computer and use it in GitHub Desktop.
Parse iOS SDKでPFObjectのサブクラスを登録し忘れないようにする ref: http://qiita.com/roothybrid7/items/2eff484f1a87f0776925
This file contains hidden or 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
// Armor.h | |
@interface Armor : PFObject<PFSubclassing> | |
+ (NSString *)parseClassName; | |
@end | |
// Armor.m | |
// 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 { | |
__weak typeof(self) weakSelf = self; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
[weakSelf registerSubclass]; | |
}); | |
} | |
+ (NSString *)parseClassName { | |
return @"Armor"; | |
} | |
@end | |
// AppDelegate.m | |
#import <Parse/Parse.h> | |
//#import "Armor.h" // これと | |
- (BOOL)application:(UIApplication *)application | |
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// [Armor registerSubclass]; // これはいらない | |
[Parse setApplicationId:parseAppId clientKey:parseClientKey]; | |
} |
This file contains hidden or 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
// Armor.h | |
@interface Armor : PFObject<PFSubclassing> | |
+ (NSString *)parseClassName; | |
@end | |
// Armor.m | |
// Import this header to let Armor know that PFObject privately provides most | |
// of the methods for PFSubclassing. | |
#import <Parse/PFObject+Subclass.h> | |
@implementation Armor | |
+ (NSString *)parseClassName { | |
return @"Armor"; | |
} | |
@end | |
// AppDelegate.m | |
#import <Parse/Parse.h> | |
#import "Armor.h" // これと | |
- (BOOL)application:(UIApplication *)application | |
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
[Armor registerSubclass]; // この箇所 | |
[Parse setApplicationId:parseAppId clientKey:parseClientKey]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment