This commit is contained in:
Giuseppe Nucifora 2016-01-16 15:36:06 +01:00
parent 58784dda8a
commit df529258e0
5 changed files with 33 additions and 7 deletions

View File

@ -29,8 +29,12 @@
PNUser *user = [PNUser currentUser]; PNUser *user = [PNUser currentUser];
[user setFirstName:@"peppe"]; [user setFirstName:@"peppe"];
[user setLastName:@"nucifora"]; [user setLastName:@"nucifora"];
[user setUsername:@"giuseppe.nucifora"];
NSLog(@"user : %@",[user getObject]);
PNUser *object = [user saveLocally];
NSLog(@"User : %@",[object getObject]);
return YES; return YES;
} }

View File

@ -10,6 +10,8 @@ target 'PNObject_Example' do
pod 'UIDevice-Utils' pod 'UIDevice-Utils'
pod 'AFNetworking' pod 'AFNetworking'
pod 'nv-ios-http-status' pod 'nv-ios-http-status'
pod 'NSString-Helper'
pod 'CodFis-Helper'
end end
target 'PNObject_Tests' do target 'PNObject_Tests' do

View File

@ -40,5 +40,7 @@ s.dependency 'PEAR-FileManager-iOS'
s.dependency 'NSDate_Utils' s.dependency 'NSDate_Utils'
s.dependency 'UIDevice-Utils' s.dependency 'UIDevice-Utils'
s.dependency 'nv-ios-http-status' s.dependency 'nv-ios-http-status'
s.dependency 'NSString-Helper'
s.dependency 'CodFis-Helper'
end end

View File

@ -37,16 +37,29 @@ static bool isFirstAccess = YES;
} }
- (NSString * _Nullable) objectName:(id _Nonnull) object { - (NSString * _Nullable) objectName:(id _Nonnull) object {
NSString *className;
BOOL isPNObjectSubclass = [[object class] isSubclassOfClass:[PNObject class]]; BOOL isPNObjectSubclass = [[object class] isSubclassOfClass:[PNObject class]];
if(isPNObjectSubclass) { if(isPNObjectSubclass) {
if ([[object class] conformsToProtocol:@protocol(PNObjectSubclassing)] && [(PNObject*)[object subClassDelegate] respondsToSelector:@selector(objectClassName)]) { if ([[object class] conformsToProtocol:@protocol(PNObjectSubclassing)]) {
return className = (NSString *)[[(PNObject*)object class] performSelector:@selector(objectClassName)]; NSLogDebug(@"%@",[object subClassDelegate]);
//if ([[object subClassDelegate] respondsToSelector:@selector(objectClassName)]) {
@try {
return (NSString *)[[object class] performSelector:@selector(objectClassName)];
}
@catch (NSException *exception) {
return nil;
}
@finally {
}
//}
} }
} }
return nil; return nil;
@ -117,12 +130,10 @@ static bool isFirstAccess = YES;
if ([[object class] conformsToProtocol:@protocol(PNObjectSubclassing)]) { if ([[object class] conformsToProtocol:@protocol(PNObjectSubclassing)]) {
id value;
SEL selector = NSSelectorFromString(@"getObject"); SEL selector = NSSelectorFromString(@"getObject");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[PNObject class] instanceMethodSignatureForSelector:selector]]; NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[PNObject class] instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector]; [invocation setSelector:selector];
[invocation setTarget:value]; [invocation setTarget:object];
[invocation invoke]; [invocation invoke];
NSDictionary *objectDict; NSDictionary *objectDict;

View File

@ -71,9 +71,16 @@ static bool isFirstAccess = YES;
[self doesNotRecognizeSelector:_cmd]; [self doesNotRecognizeSelector:_cmd];
} }
self = [super init]; self = [super init];
if (self) {
[self setSubClassDelegate:self];
}
return self; return self;
} }
- (void) setEmail:(NSString *)email {
}
#pragma mark PNObjectSubclassing Protocol #pragma mark PNObjectSubclassing Protocol
+ (NSDictionary *)objcetMapping { + (NSDictionary *)objcetMapping {