mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 04:20:21 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user