Last active
August 29, 2015 14:21
-
-
Save hunterbridges/eaae29b4d331c7d310ab to your computer and use it in GitHub Desktop.
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
#import "PFObject+SubclassInit.h" | |
@implementation PFObject (SubclassInit) | |
+ (instancetype)subclass | |
{ | |
Class klass = self; | |
SEL selector = @selector(parseClassName); | |
if ([klass respondsToSelector:selector]) { | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Warc-performSelector-leaks" | |
NSString *className = [klass performSelector:selector]; | |
#pragma clang diagnostic pop | |
return [[self alloc] initWithClassName:className]; | |
} else { | |
NSException *exc = [[NSException alloc] initWithName:NSInternalInconsistencyException | |
reason:@"Not a PFSubclassing class" | |
userInfo:nil]; | |
[exc raise]; | |
return nil; | |
} | |
} | |
+ (instancetype)subclassWithoutDataWithObjectId:(NSString *)objectId | |
{ | |
Class klass = self; | |
SEL selector = @selector(parseClassName); | |
if ([klass respondsToSelector:selector]) { | |
SEL selector = @selector(objectWithoutDataWithObjectId:); | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Warc-performSelector-leaks" | |
return [klass performSelector:selector withObject:objectId]; | |
#pragma clang diagnostic pop | |
} else { | |
NSException *exc = [[NSException alloc] initWithName:NSInternalInconsistencyException | |
reason:@"Not a PFSubclassing class" | |
userInfo:nil]; | |
[exc raise]; | |
return nil; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment