Use runtime checks for NSOrderedSet class to enable building against iOS 4.x and OS X 10.6. fixes #568, #545

This commit is contained in:
Blake Watters
2012-02-25 11:44:13 -05:00
parent 161ea6aa95
commit e66f65bb5e
2 changed files with 38 additions and 150 deletions

View File

@@ -129,6 +129,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
- (id)transformValue:(id)value atKeyPath:keyPath toType:(Class)destinationType {
RKLogTrace(@"Found transformable value at keyPath '%@'. Transforming from type '%@' to '%@'", keyPath, NSStringFromClass([value class]), NSStringFromClass(destinationType));
Class sourceType = [value class];
Class orderedSetClass = NSClassFromString(@"NSOrderedSet");
if ([sourceType isSubclassOfClass:[NSString class]]) {
if ([destinationType isSubclassOfClass:[NSDate class]]) {
@@ -160,7 +161,7 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
if ([destinationType isSubclassOfClass:[NSArray class]]) {
return [(NSSet*)value allObjects];
}
} else if ([sourceType isSubclassOfClass:[NSOrderedSet class]]) {
} else if (orderedSetClass && [sourceType isSubclassOfClass:orderedSetClass]) {
// OrderedSet -> Array
if ([destinationType isSubclassOfClass:[NSArray class]]) {
return [(NSOrderedSet*)value array];
@@ -171,8 +172,8 @@ BOOL RKObjectIsValueEqualToValue(id sourceValue, id destinationValue) {
return [NSSet setWithArray:value];
}
// Array -> OrderedSet
if ([destinationType isSubclassOfClass:[NSOrderedSet class]]) {
return [NSOrderedSet orderedSetWithArray:value];
if (orderedSetClass && [destinationType isSubclassOfClass:orderedSetClass]) {
return [orderedSetClass orderedSetWithArray:value];
}
} else if ([sourceType isSubclassOfClass:[NSNumber class]] && [destinationType isSubclassOfClass:[NSDate class]]) {
// Number -> Date