diff --git a/Example/PNObject/PNObjectAppDelegate.m b/Example/PNObject/PNObjectAppDelegate.m index 3f5c88d..01570c4 100644 --- a/Example/PNObject/PNObjectAppDelegate.m +++ b/Example/PNObject/PNObjectAppDelegate.m @@ -29,8 +29,12 @@ PNUser *user = [PNUser currentUser]; [user setFirstName:@"peppe"]; [user setLastName:@"nucifora"]; + [user setUsername:@"giuseppe.nucifora"]; - NSLog(@"user : %@",[user getObject]); + + PNUser *object = [user saveLocally]; + + NSLog(@"User : %@",[object getObject]); return YES; } diff --git a/Example/Podfile b/Example/Podfile index 29911ae..b542157 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -10,6 +10,8 @@ target 'PNObject_Example' do pod 'UIDevice-Utils' pod 'AFNetworking' pod 'nv-ios-http-status' + pod 'NSString-Helper' + pod 'CodFis-Helper' end target 'PNObject_Tests' do diff --git a/PNObject.podspec b/PNObject.podspec index 3974782..8d81489 100644 --- a/PNObject.podspec +++ b/PNObject.podspec @@ -40,5 +40,7 @@ s.dependency 'PEAR-FileManager-iOS' s.dependency 'NSDate_Utils' s.dependency 'UIDevice-Utils' s.dependency 'nv-ios-http-status' +s.dependency 'NSString-Helper' +s.dependency 'CodFis-Helper' end diff --git a/Pod/Classes/PNObjectModel.m b/Pod/Classes/PNObjectModel.m index b80f61b..20bfc3e 100644 --- a/Pod/Classes/PNObjectModel.m +++ b/Pod/Classes/PNObjectModel.m @@ -37,16 +37,29 @@ static bool isFirstAccess = YES; } - (NSString * _Nullable) objectName:(id _Nonnull) object { - NSString *className; BOOL isPNObjectSubclass = [[object class] isSubclassOfClass:[PNObject class]]; 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; @@ -117,12 +130,10 @@ static bool isFirstAccess = YES; if ([[object class] conformsToProtocol:@protocol(PNObjectSubclassing)]) { - id value; - SEL selector = NSSelectorFromString(@"getObject"); NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[PNObject class] instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; - [invocation setTarget:value]; + [invocation setTarget:object]; [invocation invoke]; NSDictionary *objectDict; diff --git a/Pod/Classes/User/PNUser.m b/Pod/Classes/User/PNUser.m index 92047ee..af1245f 100644 --- a/Pod/Classes/User/PNUser.m +++ b/Pod/Classes/User/PNUser.m @@ -71,9 +71,16 @@ static bool isFirstAccess = YES; [self doesNotRecognizeSelector:_cmd]; } self = [super init]; + if (self) { + [self setSubClassDelegate:self]; + } return self; } +- (void) setEmail:(NSString *)email { + +} + #pragma mark PNObjectSubclassing Protocol + (NSDictionary *)objcetMapping {