From 6134edbd1202c0136964f58c8d97798fb5219955 Mon Sep 17 00:00:00 2001 From: Giuseppe Nucifora Date: Tue, 3 May 2016 17:57:01 +0200 Subject: [PATCH] no message --- Pod/Classes/PNClasses/PNAddress.m | 2 +- Pod/Classes/PNClasses/PNInstallation.m | 2 +- Pod/Classes/PNClasses/PNUser.m | 2 +- Pod/Classes/PNObject+Protected.m | 4 ++-- Pod/Classes/PNObject.m | 12 ++++++++---- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Pod/Classes/PNClasses/PNAddress.m b/Pod/Classes/PNClasses/PNAddress.m index d123a10..b366053 100644 --- a/Pod/Classes/PNClasses/PNAddress.m +++ b/Pod/Classes/PNClasses/PNAddress.m @@ -25,7 +25,7 @@ @"street":@"street", @"number":@"number", @"zip":@"zip", - @"location":@{@"key":@"location",@"type":@"PNLocation"}, + @"location":@{PNObjectMappingKey:@"location",PNObjectMappingType:@"PNLocation"}, }; return mapping; } diff --git a/Pod/Classes/PNClasses/PNInstallation.m b/Pod/Classes/PNClasses/PNInstallation.m index 08bae50..c8bcda4 100644 --- a/Pod/Classes/PNClasses/PNInstallation.m +++ b/Pod/Classes/PNClasses/PNInstallation.m @@ -32,7 +32,7 @@ static bool isFirstAccess = YES; + (NSDictionary *)objcetMapping { - NSDictionary *mapping = @{@"user":@{@"key":@"user",@"type":[[[PNObjectConfig sharedInstance] userSubClass] PNObjClassName]}, + NSDictionary *mapping = @{@"user":@{PNObjectMappingKey:@"user",PNObjectMappingType:[[[PNObjectConfig sharedInstance] userSubClass] PNObjClassName]}, @"deviceType":@"deviceType", @"deviceModel":@"deviceModel", @"deviceName":@"deviceName", diff --git a/Pod/Classes/PNClasses/PNUser.m b/Pod/Classes/PNClasses/PNUser.m index 361e9b9..62a269a 100644 --- a/Pod/Classes/PNClasses/PNUser.m +++ b/Pod/Classes/PNClasses/PNUser.m @@ -409,7 +409,7 @@ static bool isFirstAccess = YES; @"sex":@"sex", @"birthDate":@"birthDate", @"phone":@"phone", - @"password":@{@"key":@"password",@"type":[PNObjcPassword PNObjClassName]}, + @"password":@{PNObjectMappingKey:@"password",PNObjectMappingType:[PNObjcPassword PNObjClassName]}, @"hasAcceptedPrivacy":@"hasAcceptedPrivacy", @"hasAcceptedNewsletter":@"hasAcceptedNewsletter", @"hasVerifiedEmail":@"hasVerifiedEmail", diff --git a/Pod/Classes/PNObject+Protected.m b/Pod/Classes/PNObject+Protected.m index 16b67d1..567448a 100644 --- a/Pod/Classes/PNObject+Protected.m +++ b/Pod/Classes/PNObject+Protected.m @@ -190,8 +190,8 @@ id mappingValue = [self.JSONObjectMap valueForKey:propertyName]; if([mappingValue isKindOfClass:NSDictionary.class]) { - mappedJSONKey = [mappingValue valueForKey:@"key"]; - mappedJSONType = [mappingValue valueForKey:@"type"]; + mappedJSONKey = [mappingValue valueForKey:PNObjectMappingKey]; + mappedJSONType = [mappingValue valueForKey:PNObjectMappingType]; } else { mappedJSONKey = mappingValue; } diff --git a/Pod/Classes/PNObject.m b/Pod/Classes/PNObject.m index 00d7ddb..1e5eea4 100644 --- a/Pod/Classes/PNObject.m +++ b/Pod/Classes/PNObject.m @@ -206,6 +206,7 @@ NSString * const PNObjectMappingSelector = @"selector"; NSString *mappedJSONKey; NSString *mappedJSONType; + NSString *type; if (self.JSON && [[self.JSON allKeys] count] == 0) { self.JSON = [[NSMutableDictionary alloc] initWithDictionary:[self reverseMapping]]; @@ -217,14 +218,17 @@ NSString * const PNObjectMappingSelector = @"selector"; id mappingValue = [self.JSONObjectMap objectForKey:propertyName]; if([mappingValue isKindOfClass:NSDictionary.class]) { - mappedJSONKey = [mappingValue valueForKey:@"key"]; - mappedJSONType = [mappingValue valueForKey:@"type"]; + mappedJSONKey = [mappingValue valueForKey:PNObjectMappingKey]; + mappedJSONType = [mappingValue valueForKey:PNObjectMappingType]; + } else { mappedJSONKey = mappingValue; mappedJSONType = [properties valueForKey:propertyName]; } - NSLog(@"PropertyName PropertyType: %@ - %@",propertyName,mappedJSONType); + type = [properties valueForKey:propertyName]; + + NSLog(@"PropertyName MappedJsonType PropertyType: %@ - %@ - %@",propertyName,mappedJSONType,type); id value; @@ -321,7 +325,7 @@ NSString * const PNObjectMappingSelector = @"selector"; [JSON setValue:arr forKey:propertyName]; } - }[mappedJSONType] ?: ^{ + }[type] ?: ^{ BOOL isPNObjectSubclass = [NSClassFromString(mappedJSONType) isSubclassOfClass:[PNObject class]]; if(isPNObjectSubclass) {