Skip to content

Commit

Permalink
Add support for mapping an array to an NSOrderedSet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Morton committed Jan 13, 2012
1 parent 3cf2ea5 commit 0f3f3d5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Code/ObjectMapping/RKObjectMappingOperation.m
Expand Up @@ -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]];
Expand Down

0 comments on commit 0f3f3d5

Please sign in to comment.