Permalink
Browse files

Add support for mapping an array to an NSOrderedSet.

  • Loading branch information...
1 parent 3cf2ea5 commit 0f3f3d57029bf4dcdf7043ed4fd3664fbe00c191 @bmorton bmorton committed Jan 13, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 Code/ObjectMapping/RKObjectMappingOperation.m
@@ -160,11 +160,20 @@ - (id)transformValue:(id)value atKeyPath:keyPath toType:(Class)destinationType {
if ([destinationType isSubclassOfClass:[NSArray class]]) {
return [(NSSet*)value allObjects];
}
+ } else if ([sourceType isSubclassOfClass:[NSOrderedSet class]]) {
+ // OrderedSet -> Array
+ if ([destinationType isSubclassOfClass:[NSArray class]]) {
+ return [(NSOrderedSet*)value array];
+ }
} else if ([sourceType isSubclassOfClass:[NSArray class]]) {
// Array -> Set
if ([destinationType isSubclassOfClass:[NSSet class]]) {
return [NSSet setWithArray:value];
}
+ // Array -> OrderedSet
+ if ([destinationType isSubclassOfClass:[NSOrderedSet class]]) {
+ return [NSOrderedSet orderedSetWithArray:value];
+ }
} else if ([sourceType isSubclassOfClass:[NSNumber class]] && [destinationType isSubclassOfClass:[NSDate class]]) {
// Number -> Date
return [NSDate dateWithTimeIntervalSince1970:[(NSNumber*)value intValue]];

0 comments on commit 0f3f3d5

Please sign in to comment.