diff --git a/OCMapper.podspec b/OCMapper.podspec index b613293..2e90231 100644 --- a/OCMapper.podspec +++ b/OCMapper.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'OCMapper' - s.version = '1.0.3' + s.version = '1.5' s.summary = 'NSDictionary to NSObject Mapper' s.homepage = 'https://github.com/aryaxt/OCMapper' s.license = { @@ -8,7 +8,7 @@ Pod::Spec.new do |s| :file => 'License.txt' } s.author = {'Aryan Ghassemi' => 'https://github.com/aryaxt/OCMapper'} - s.source = {:git => 'https://github.com/aryaxt/OCMapper.git', :tag => '1.0.3'} + s.source = {:git => 'https://github.com/aryaxt/OCMapper.git', :tag => '1.5'} s.source_files = 'OCMapper/Source/*.{h,m}','OCMapper/Source/Categories/*.{h,m}','OCMapper/Source/Logging Provider/*.{h,m}','OCMapper/Source/Instance Provider/*.{h,m}','OCMapper/Source/Mapping Provider/*.{h,m}','OCMapper/Source/Mapping Provider/In Code Mapping/*.{h,m}','OCMapper/Source/Mapping Provider/PLIST Mapping/*.{h,m}','OCMapper/Source/Mapping Provider/XML Mapping/*.{h,m}' s.framework = 'Foundation' s.requires_arc = true diff --git a/OCMapper.xcodeproj/project.pbxproj b/OCMapper.xcodeproj/project.pbxproj index ff1c34d..08c8822 100644 --- a/OCMapper.xcodeproj/project.pbxproj +++ b/OCMapper.xcodeproj/project.pbxproj @@ -687,6 +687,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "OCMapper/OCMapper-Prefix.pch"; INFOPLIST_FILE = "OCMapper/OCMapper-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; PRODUCT_NAME = OCMapper; WRAPPER_EXTENSION = app; }; @@ -698,6 +699,7 @@ GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "OCMapper/OCMapper-Prefix.pch"; INFOPLIST_FILE = "OCMapper/OCMapper-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 6.0; PRODUCT_NAME = OCMapper; WRAPPER_EXTENSION = app; }; diff --git a/OCMapper/Source/Mapping Provider/XML Mapping/XMLMappingProvider.h b/OCMapper/Source/Mapping Provider/XML Mapping/XMLMappingProvider.h deleted file mode 100644 index 76fd781..0000000 --- a/OCMapper/Source/Mapping Provider/XML Mapping/XMLMappingProvider.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// XMLMappingProvider.h -// OCMapper -// -// Created by Aryan Gh on 4/20/13. -// Copyright (c) 2013 Aryan Ghassemi. All rights reserved. -// - -#import -#import "MappingProvider.h" - -@interface XMLMappingProvider : NSObject - -- (id)initWithXmlFile:(NSString *)fileName; - -@end diff --git a/OCMapper/Source/Mapping Provider/XML Mapping/XMLMappingProvider.m b/OCMapper/Source/Mapping Provider/XML Mapping/XMLMappingProvider.m deleted file mode 100644 index 47b14ce..0000000 --- a/OCMapper/Source/Mapping Provider/XML Mapping/XMLMappingProvider.m +++ /dev/null @@ -1,38 +0,0 @@ -// -// XMLMappingProvider.m -// OCMapper -// -// Created by Aryan Gh on 4/20/13. -// Copyright (c) 2013 Aryan Ghassemi. All rights reserved. -// - -#import "XMLMappingProvider.h" - -@implementation XMLMappingProvider - -#pragma mark - Initialization - - -- (id)initWithXmlFile:(NSString *)fileName -{ - if (self = [super init]) - { - NSString *filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"xml"]; - - } - - return self; -} - -#pragma mark - MappingProvider Methods - - -- (ObjectMappingInfo *)mappingInfoForClass:(Class)class andDictionaryKey:(NSString *)source -{ - return nil; -} - -- (NSDateFormatter *)dateFormatterForClass:(Class)class andProperty:(NSString *)property -{ - return nil; -} - -@end diff --git a/OCMapper/Source/ObjectMapper.m b/OCMapper/Source/ObjectMapper.m index 0a73c66..f7b94ad 100644 --- a/OCMapper/Source/ObjectMapper.m +++ b/OCMapper/Source/ObjectMapper.m @@ -88,9 +88,6 @@ - (id)init - (id)objectFromSource:(id)source toInstanceOfClass:(Class)class { - if (!_mappingProvider) - @throw ([NSException exceptionWithName:@"MissingMappingProvider" reason:@"Mapping provider is not set" userInfo:nil]); - if ([source isKindOfClass:[NSDictionary class]]) { ILog(@"____________________ Mapping Dictionary to instance [%@] ____________________", NSStringFromClass(class)); @@ -169,8 +166,14 @@ - (NSArray *)processDictionaryFromArray:(NSArray *)array return result; } -- (NSDictionary *)processDictionaryFromObject:(NSObject *)object +- (id)processDictionaryFromObject:(NSObject *)object { + // For example when we are mapping an array of string, we shouldn't try to map the string objects inside the array + if ([NSBundle mainBundle] != [NSBundle bundleForClass:object.class] && [object class] != [NSArray class]) + { + return object; + } + NSMutableDictionary *props = [NSMutableDictionary dictionary]; Class currentClass = [object class]; @@ -303,7 +306,7 @@ - (id)processDictionary:(NSDictionary *)source forClass:(Class)class if ([value isKindOfClass:[NSDictionary class]]) { objectType = NSClassFromString([NSString stringWithFormat:@"%@.%@", - [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] + [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleNameKey] ,[self typeForProperty:propertyName andClass:class]]); } @@ -383,6 +386,8 @@ - (id)processDictionary:(NSDictionary *)source forClass:(Class)class return instanceProvider; } + ELog(@"Could not find an instance provider that can handle class '%@'", NSStringFromClass(class)); + return nil; } @@ -427,7 +432,7 @@ - (Class)classFromString:(NSString *)className return clazz; }; - NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; + NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleNameKey]; NSString *predictedClassName = className; if (testClassName(predictedClassName)) { return testClassName(predictedClassName); }