Skip to content

Commit e66f65b

Browse files
committed
Use runtime checks for NSOrderedSet class to enable building against iOS 4.x and OS X 10.6. fixes RestKit#568, RestKit#545
1 parent 161ea6a commit e66f65b

File tree

2 files changed

+38
-150
lines changed

2 files changed

+38
-150
lines changed

Code/ObjectMapping/RKObjectMappingOperation.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ - (NSDate*)parseDateFromString:(NSString*)string {
129129
- (id)transformValue:(id)value atKeyPath:keyPath toType:(Class)destinationType {
130130
RKLogTrace(@"Found transformable value at keyPath '%@'. Transforming from type '%@' to '%@'", keyPath, NSStringFromClass([value class]), NSStringFromClass(destinationType));
131131
Class sourceType = [value class];
132+
Class orderedSetClass = NSClassFromString(@"NSOrderedSet");
132133

133134
if ([sourceType isSubclassOfClass:[NSString class]]) {
134135
if ([destinationType isSubclassOfClass:[NSDate class]]) {
@@ -160,7 +161,7 @@ - (id)transformValue:(id)value atKeyPath:keyPath toType:(Class)destinationType {
160161
if ([destinationType isSubclassOfClass:[NSArray class]]) {
161162
return [(NSSet*)value allObjects];
162163
}
163-
} else if ([sourceType isSubclassOfClass:[NSOrderedSet class]]) {
164+
} else if (orderedSetClass && [sourceType isSubclassOfClass:orderedSetClass]) {
164165
// OrderedSet -> Array
165166
if ([destinationType isSubclassOfClass:[NSArray class]]) {
166167
return [(NSOrderedSet*)value array];
@@ -171,8 +172,8 @@ - (id)transformValue:(id)value atKeyPath:keyPath toType:(Class)destinationType {
171172
return [NSSet setWithArray:value];
172173
}
173174
// Array -> OrderedSet
174-
if ([destinationType isSubclassOfClass:[NSOrderedSet class]]) {
175-
return [NSOrderedSet orderedSetWithArray:value];
175+
if (orderedSetClass && [destinationType isSubclassOfClass:orderedSetClass]) {
176+
return [orderedSetClass orderedSetWithArray:value];
176177
}
177178
} else if ([sourceType isSubclassOfClass:[NSNumber class]] && [destinationType isSubclassOfClass:[NSDate class]]) {
178179
// Number -> Date

Examples/RKMacOSX/RKMacOSX.xcodeproj/project.pbxproj

Lines changed: 34 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -7,107 +7,54 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
25A8BA7A14F9458C005C7314 /* RestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2534806B14F941A900565CED /* RestKit.framework */; };
1011
25D63919135184CE000879B1 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D63918135184CE000879B1 /* Cocoa.framework */; };
1112
25D63923135184CE000879B1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 25D63921135184CE000879B1 /* InfoPlist.strings */; };
1213
25D63926135184CE000879B1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 25D63925135184CE000879B1 /* main.m */; };
1314
25D63929135184CE000879B1 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 25D63927135184CE000879B1 /* Credits.rtf */; };
1415
25D6392C135184CE000879B1 /* RKMacOSXAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 25D6392B135184CE000879B1 /* RKMacOSXAppDelegate.m */; };
1516
25D6392F135184CF000879B1 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 25D6392D135184CF000879B1 /* MainMenu.xib */; };
16-
25D6397813518514000879B1 /* libRestKitCoreData.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397213518514000879B1 /* libRestKitCoreData.a */; };
17-
25D6397913518514000879B1 /* libRestKitJSONParserJSONKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397313518514000879B1 /* libRestKitJSONParserJSONKit.a */; };
18-
25D6397A13518514000879B1 /* libRestKitNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397413518514000879B1 /* libRestKitNetwork.a */; };
19-
25D6397B13518514000879B1 /* libRestKitObjectMapping.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397513518514000879B1 /* libRestKitObjectMapping.a */; };
20-
25D6397C13518514000879B1 /* libRestKitSupport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397613518514000879B1 /* libRestKitSupport.a */; };
2117
25D6397F13518574000879B1 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397E13518574000879B1 /* CoreData.framework */; };
2218
25D639811351858A000879B1 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D639801351858A000879B1 /* AppKit.framework */; };
2319
25D63983135185B6000879B1 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D63982135185B6000879B1 /* SystemConfiguration.framework */; };
2420
/* End PBXBuildFile section */
2521

2622
/* Begin PBXContainerItemProxy section */
27-
25D63957135184F1000879B1 /* PBXContainerItemProxy */ = {
23+
2534806614F941A900565CED /* PBXContainerItemProxy */ = {
2824
isa = PBXContainerItemProxy;
2925
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
3026
proxyType = 2;
31-
remoteGlobalIDString = 253A07FC1255161B00976E89;
32-
remoteInfo = RestKitNetwork;
33-
};
34-
25D63959135184F1000879B1 /* PBXContainerItemProxy */ = {
35-
isa = PBXContainerItemProxy;
36-
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
37-
proxyType = 2;
38-
remoteGlobalIDString = 253A08031255162C00976E89;
39-
remoteInfo = RestKitObjectMapping;
40-
};
41-
25D6395B135184F1000879B1 /* PBXContainerItemProxy */ = {
42-
isa = PBXContainerItemProxy;
43-
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
44-
proxyType = 2;
45-
remoteGlobalIDString = 253A080C12551D3000976E89;
46-
remoteInfo = RestKitSupport;
47-
};
48-
25D6395D135184F1000879B1 /* PBXContainerItemProxy */ = {
49-
isa = PBXContainerItemProxy;
50-
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
51-
proxyType = 2;
52-
remoteGlobalIDString = 2590E64F125231F600531FA8;
53-
remoteInfo = "RestKitJSONParser+YAJL";
54-
};
55-
25D6395F135184F1000879B1 /* PBXContainerItemProxy */ = {
56-
isa = PBXContainerItemProxy;
57-
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
58-
proxyType = 2;
59-
remoteGlobalIDString = 2590E66B1252353700531FA8;
60-
remoteInfo = "RestKitJSONParser+SBJSON";
61-
};
62-
25D63961135184F1000879B1 /* PBXContainerItemProxy */ = {
63-
isa = PBXContainerItemProxy;
64-
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
65-
proxyType = 2;
66-
remoteGlobalIDString = 73057FD11331AD2E001908EE;
67-
remoteInfo = "RestKitJSONParser+JSONKit";
68-
};
69-
25D63963135184F1000879B1 /* PBXContainerItemProxy */ = {
70-
isa = PBXContainerItemProxy;
71-
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
72-
proxyType = 2;
73-
remoteGlobalIDString = 25BD43BD1340315800DBACDD;
74-
remoteInfo = "RestKitXMLParser+Libxml";
27+
remoteGlobalIDString = 25160D1614564E810060A5C5;
28+
remoteInfo = RestKit;
7529
};
76-
25D63965135184F1000879B1 /* PBXContainerItemProxy */ = {
30+
2534806814F941A900565CED /* PBXContainerItemProxy */ = {
7731
isa = PBXContainerItemProxy;
7832
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
7933
proxyType = 2;
80-
remoteGlobalIDString = 253A081412551D5300976E89;
81-
remoteInfo = RestKitCoreData;
34+
remoteGlobalIDString = 25160D2614564E820060A5C5;
35+
remoteInfo = RestKitTests;
8236
};
83-
25D63967135184F1000879B1 /* PBXContainerItemProxy */ = {
37+
2534806A14F941A900565CED /* PBXContainerItemProxy */ = {
8438
isa = PBXContainerItemProxy;
8539
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
8640
proxyType = 2;
87-
remoteGlobalIDString = 2523360511E79F090048F9B4;
88-
remoteInfo = RestKitThree20;
41+
remoteGlobalIDString = 25160E62145651060060A5C5;
42+
remoteInfo = RestKitFramework;
8943
};
90-
25D63969135184F1000879B1 /* PBXContainerItemProxy */ = {
44+
2534806C14F941A900565CED /* PBXContainerItemProxy */ = {
9145
isa = PBXContainerItemProxy;
9246
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
9347
proxyType = 2;
94-
remoteGlobalIDString = 3F6C39A510FE5C95008F47C5;
95-
remoteInfo = UISpec;
48+
remoteGlobalIDString = 25160E78145651060060A5C5;
49+
remoteInfo = RestKitFrameworkTests;
9650
};
9751
25D6397013518504000879B1 /* PBXContainerItemProxy */ = {
9852
isa = PBXContainerItemProxy;
9953
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
10054
proxyType = 1;
101-
remoteGlobalIDString = 255B7588133BABBF00ED76AD;
55+
remoteGlobalIDString = 25160D1514564E810060A5C5;
10256
remoteInfo = RestKit;
10357
};
104-
25FB6D9F13E4848200F48969 /* PBXContainerItemProxy */ = {
105-
isa = PBXContainerItemProxy;
106-
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
107-
proxyType = 2;
108-
remoteGlobalIDString = 20808DBD13DE8CDC000A156A;
109-
remoteInfo = "RestKitJSONParser+NXJSON";
110-
};
11158
/* End PBXContainerItemProxy section */
11259

11360
/* Begin PBXFileReference section */
@@ -141,14 +88,10 @@
14188
isa = PBXFrameworksBuildPhase;
14289
buildActionMask = 2147483647;
14390
files = (
91+
25A8BA7A14F9458C005C7314 /* RestKit.framework in Frameworks */,
14492
25D63983135185B6000879B1 /* SystemConfiguration.framework in Frameworks */,
14593
25D639811351858A000879B1 /* AppKit.framework in Frameworks */,
14694
25D6397F13518574000879B1 /* CoreData.framework in Frameworks */,
147-
25D6397813518514000879B1 /* libRestKitCoreData.a in Frameworks */,
148-
25D6397913518514000879B1 /* libRestKitJSONParserJSONKit.a in Frameworks */,
149-
25D6397A13518514000879B1 /* libRestKitNetwork.a in Frameworks */,
150-
25D6397B13518514000879B1 /* libRestKitObjectMapping.a in Frameworks */,
151-
25D6397C13518514000879B1 /* libRestKitSupport.a in Frameworks */,
15295
25D63919135184CE000879B1 /* Cocoa.framework in Frameworks */,
15396
);
15497
runOnlyForDeploymentPostprocessing = 0;
@@ -222,17 +165,10 @@
222165
25D63939135184F0000879B1 /* Products */ = {
223166
isa = PBXGroup;
224167
children = (
225-
25D63958135184F1000879B1 /* libRestKitNetwork.a */,
226-
25D6395A135184F1000879B1 /* libRestKitObjectMapping.a */,
227-
25D6395C135184F1000879B1 /* libRestKitSupport.a */,
228-
25FB6DA013E4848200F48969 /* libRestKitJSONParserNXJSON.a */,
229-
25D6395E135184F1000879B1 /* libRestKitJSONParserYAJL.a */,
230-
25D63960135184F1000879B1 /* libRestKitJSONParserSBJSON.a */,
231-
25D63962135184F1000879B1 /* libRestKitJSONParserJSONKit.a */,
232-
25D63964135184F1000879B1 /* libRestKitXMLParserLibxml.a */,
233-
25D63966135184F1000879B1 /* libRestKitCoreData.a */,
234-
25D63968135184F1000879B1 /* libRestKitThree20.a */,
235-
25D6396A135184F1000879B1 /* RestKitSpecs.app */,
168+
2534806714F941A900565CED /* libRestKit.a */,
169+
2534806914F941A900565CED /* RestKitTests.octest */,
170+
2534806B14F941A900565CED /* RestKit.framework */,
171+
2534806D14F941A900565CED /* RestKitFrameworkTests.octest */,
236172
);
237173
name = Products;
238174
sourceTree = "<group>";
@@ -304,81 +240,32 @@
304240
/* End PBXProject section */
305241

306242
/* Begin PBXReferenceProxy section */
307-
25D63958135184F1000879B1 /* libRestKitNetwork.a */ = {
243+
2534806714F941A900565CED /* libRestKit.a */ = {
308244
isa = PBXReferenceProxy;
309245
fileType = archive.ar;
310-
path = libRestKitNetwork.a;
311-
remoteRef = 25D63957135184F1000879B1 /* PBXContainerItemProxy */;
246+
path = libRestKit.a;
247+
remoteRef = 2534806614F941A900565CED /* PBXContainerItemProxy */;
312248
sourceTree = BUILT_PRODUCTS_DIR;
313249
};
314-
25D6395A135184F1000879B1 /* libRestKitObjectMapping.a */ = {
250+
2534806914F941A900565CED /* RestKitTests.octest */ = {
315251
isa = PBXReferenceProxy;
316-
fileType = archive.ar;
317-
path = libRestKitObjectMapping.a;
318-
remoteRef = 25D63959135184F1000879B1 /* PBXContainerItemProxy */;
252+
fileType = wrapper.cfbundle;
253+
path = RestKitTests.octest;
254+
remoteRef = 2534806814F941A900565CED /* PBXContainerItemProxy */;
319255
sourceTree = BUILT_PRODUCTS_DIR;
320256
};
321-
25D6395C135184F1000879B1 /* libRestKitSupport.a */ = {
257+
2534806B14F941A900565CED /* RestKit.framework */ = {
322258
isa = PBXReferenceProxy;
323-
fileType = archive.ar;
324-
path = libRestKitSupport.a;
325-
remoteRef = 25D6395B135184F1000879B1 /* PBXContainerItemProxy */;
326-
sourceTree = BUILT_PRODUCTS_DIR;
327-
};
328-
25D6395E135184F1000879B1 /* libRestKitJSONParserYAJL.a */ = {
329-
isa = PBXReferenceProxy;
330-
fileType = archive.ar;
331-
path = libRestKitJSONParserYAJL.a;
332-
remoteRef = 25D6395D135184F1000879B1 /* PBXContainerItemProxy */;
259+
fileType = wrapper.framework;
260+
path = RestKit.framework;
261+
remoteRef = 2534806A14F941A900565CED /* PBXContainerItemProxy */;
333262
sourceTree = BUILT_PRODUCTS_DIR;
334263
};
335-
25D63960135184F1000879B1 /* libRestKitJSONParserSBJSON.a */ = {
264+
2534806D14F941A900565CED /* RestKitFrameworkTests.octest */ = {
336265
isa = PBXReferenceProxy;
337-
fileType = archive.ar;
338-
path = libRestKitJSONParserSBJSON.a;
339-
remoteRef = 25D6395F135184F1000879B1 /* PBXContainerItemProxy */;
340-
sourceTree = BUILT_PRODUCTS_DIR;
341-
};
342-
25D63962135184F1000879B1 /* libRestKitJSONParserJSONKit.a */ = {
343-
isa = PBXReferenceProxy;
344-
fileType = archive.ar;
345-
path = libRestKitJSONParserJSONKit.a;
346-
remoteRef = 25D63961135184F1000879B1 /* PBXContainerItemProxy */;
347-
sourceTree = BUILT_PRODUCTS_DIR;
348-
};
349-
25D63964135184F1000879B1 /* libRestKitXMLParserLibxml.a */ = {
350-
isa = PBXReferenceProxy;
351-
fileType = archive.ar;
352-
path = libRestKitXMLParserLibxml.a;
353-
remoteRef = 25D63963135184F1000879B1 /* PBXContainerItemProxy */;
354-
sourceTree = BUILT_PRODUCTS_DIR;
355-
};
356-
25D63966135184F1000879B1 /* libRestKitCoreData.a */ = {
357-
isa = PBXReferenceProxy;
358-
fileType = archive.ar;
359-
path = libRestKitCoreData.a;
360-
remoteRef = 25D63965135184F1000879B1 /* PBXContainerItemProxy */;
361-
sourceTree = BUILT_PRODUCTS_DIR;
362-
};
363-
25D63968135184F1000879B1 /* libRestKitThree20.a */ = {
364-
isa = PBXReferenceProxy;
365-
fileType = archive.ar;
366-
path = libRestKitThree20.a;
367-
remoteRef = 25D63967135184F1000879B1 /* PBXContainerItemProxy */;
368-
sourceTree = BUILT_PRODUCTS_DIR;
369-
};
370-
25D6396A135184F1000879B1 /* RestKitSpecs.app */ = {
371-
isa = PBXReferenceProxy;
372-
fileType = wrapper.application;
373-
path = RestKitSpecs.app;
374-
remoteRef = 25D63969135184F1000879B1 /* PBXContainerItemProxy */;
375-
sourceTree = BUILT_PRODUCTS_DIR;
376-
};
377-
25FB6DA013E4848200F48969 /* libRestKitJSONParserNXJSON.a */ = {
378-
isa = PBXReferenceProxy;
379-
fileType = archive.ar;
380-
path = libRestKitJSONParserNXJSON.a;
381-
remoteRef = 25FB6D9F13E4848200F48969 /* PBXContainerItemProxy */;
266+
fileType = wrapper.cfbundle;
267+
path = RestKitFrameworkTests.octest;
268+
remoteRef = 2534806C14F941A900565CED /* PBXContainerItemProxy */;
382269
sourceTree = BUILT_PRODUCTS_DIR;
383270
};
384271
/* End PBXReferenceProxy section */

0 commit comments

Comments
 (0)