NSArray+FEMPropertyRepresentation.m 1000 B

1234567891011121314151617181920212223242526272829303132
  1. // For License please refer to LICENSE file in the root of FastEasyMapping project
  2. #import "NSArray+FEMPropertyRepresentation.h"
  3. #import "FEMTypeIntrospection.h"
  4. @implementation NSArray (FEMPropertyRepresentation)
  5. - (id)fem_propertyRepresentation:(objc_property_t)property {
  6. id convertedObject = self;
  7. if (property) {
  8. NSString *type = FEMPropertyTypeStringRepresentation(property);
  9. if ([type isEqualToString:@"NSSet"]) {
  10. convertedObject = [NSSet setWithArray:self];
  11. }
  12. else if ([type isEqualToString:@"NSMutableSet"]) {
  13. convertedObject = [NSMutableSet setWithArray:self];
  14. }
  15. else if ([type isEqualToString:@"NSOrderedSet"]) {
  16. convertedObject = [NSOrderedSet orderedSetWithArray:self];
  17. }
  18. else if ([type isEqualToString:@"NSMutableOrderedSet"]) {
  19. convertedObject = [NSMutableOrderedSet orderedSetWithArray:self];
  20. }
  21. else if ([type isEqualToString:@"NSMutableArray"]) {
  22. convertedObject = [NSMutableArray arrayWithArray:self];
  23. }
  24. }
  25. return convertedObject;
  26. }
  27. @end