Skip to content

Commit

Permalink
Merge remote branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mdomans committed Mar 6, 2012
2 parents 09e751e + 8d0d9fc commit 5e685d7
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 150 deletions.
7 changes: 4 additions & 3 deletions Code/ObjectMapping/RKObjectMappingOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ - (NSDate*)parseDateFromString:(NSString*)string {
- (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]]) {
Expand Down Expand Up @@ -160,7 +161,7 @@ - (id)transformValue:(id)value atKeyPath:keyPath toType:(Class)destinationType {
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];
Expand All @@ -171,8 +172,8 @@ - (id)transformValue:(id)value atKeyPath:keyPath toType:(Class)destinationType {
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
Expand Down
5 changes: 5 additions & 0 deletions Code/Support/RKDotNetDateFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

#import <Foundation/Foundation.h>

// NSRegularExpression not available until OS X 10.7 and iOS 4.0 (NS_CLASS_AVAILABLE(10_7, 4_0))
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000

/**
A subclass of NSDateFormatter that serves as translator between ASP.NET date serializations in JSON
strings and NSDate objects. This is useful for properly mapping these dates from an ASP.NET driven backend.
Expand Down Expand Up @@ -76,3 +79,5 @@
*/
- (NSString *)stringFromDate:(NSDate *)date;
@end

#endif
3 changes: 3 additions & 0 deletions Code/Support/RKDotNetDateFormatter.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#import "RKDotNetDateFormatter.h"
#import "RestKit.h"

#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000

BOOL isValidRange(NSRange rangeOfMatch);
NSTimeInterval secondsFromMilliseconds(NSTimeInterval millisecs);
NSTimeInterval millisecondsFromSeconds(NSTimeInterval seconds);
Expand Down Expand Up @@ -101,3 +103,4 @@ NSTimeInterval millisecondsFromSeconds(NSTimeInterval seconds) {
return seconds * 1000.f;
}

#endif
24 changes: 24 additions & 0 deletions Docs/Object Mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,30 @@ transformed into one or more instances of the `Article` class. Once mappable dat
key path should be assigned to the target object at the destination key path. This is the fundamental trick of object mapping and all other features
are built upon this foundation.

### Parameters

GET query parameters should be added with the new NSString method appendQueryParameters. For example,

```objc
- (void)loadArticlesContainingText:(NSString *)searchText {
NSDictionary *queryParams = [NSDictionary dictionaryWithObject:searchText forKey:@"q"];
NSString *resourcePath = [@"/articles" appendQueryParameters:queryParams];
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:resourcePath delegate:self];
}
```

POST parameters can be provided by setting the RKObjectLoader's params property:

```objc
- (void)saveArticleWithAdditionalParams:(NSDictionary *)extraPOSTParams {
RKObjectLoader* loader = [objectManager sendObject:human delegate:responseLoader block:^(RKObjectLoader* loader) {
loader.method = RKRequestMethodPOST;
loader.resourcePath = @"/articles/create";
loader.params = extraPOSTParams;
}];
}
```

## Object Mapping Fundamentals

Now that we have established a foundation for the basics of object mapping, we can explore the remaining portions of the system. We'll examine
Expand Down
181 changes: 34 additions & 147 deletions Examples/RKMacOSX/RKMacOSX.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,107 +7,54 @@
objects = {

/* Begin PBXBuildFile section */
25A8BA7A14F9458C005C7314 /* RestKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2534806B14F941A900565CED /* RestKit.framework */; };
25D63919135184CE000879B1 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D63918135184CE000879B1 /* Cocoa.framework */; };
25D63923135184CE000879B1 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 25D63921135184CE000879B1 /* InfoPlist.strings */; };
25D63926135184CE000879B1 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 25D63925135184CE000879B1 /* main.m */; };
25D63929135184CE000879B1 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 25D63927135184CE000879B1 /* Credits.rtf */; };
25D6392C135184CE000879B1 /* RKMacOSXAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 25D6392B135184CE000879B1 /* RKMacOSXAppDelegate.m */; };
25D6392F135184CF000879B1 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 25D6392D135184CF000879B1 /* MainMenu.xib */; };
25D6397813518514000879B1 /* libRestKitCoreData.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397213518514000879B1 /* libRestKitCoreData.a */; };
25D6397913518514000879B1 /* libRestKitJSONParserJSONKit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397313518514000879B1 /* libRestKitJSONParserJSONKit.a */; };
25D6397A13518514000879B1 /* libRestKitNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397413518514000879B1 /* libRestKitNetwork.a */; };
25D6397B13518514000879B1 /* libRestKitObjectMapping.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397513518514000879B1 /* libRestKitObjectMapping.a */; };
25D6397C13518514000879B1 /* libRestKitSupport.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397613518514000879B1 /* libRestKitSupport.a */; };
25D6397F13518574000879B1 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D6397E13518574000879B1 /* CoreData.framework */; };
25D639811351858A000879B1 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D639801351858A000879B1 /* AppKit.framework */; };
25D63983135185B6000879B1 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 25D63982135185B6000879B1 /* SystemConfiguration.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
25D63957135184F1000879B1 /* PBXContainerItemProxy */ = {
2534806614F941A900565CED /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 253A07FC1255161B00976E89;
remoteInfo = RestKitNetwork;
};
25D63959135184F1000879B1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 253A08031255162C00976E89;
remoteInfo = RestKitObjectMapping;
};
25D6395B135184F1000879B1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 253A080C12551D3000976E89;
remoteInfo = RestKitSupport;
};
25D6395D135184F1000879B1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 2590E64F125231F600531FA8;
remoteInfo = "RestKitJSONParser+YAJL";
};
25D6395F135184F1000879B1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 2590E66B1252353700531FA8;
remoteInfo = "RestKitJSONParser+SBJSON";
};
25D63961135184F1000879B1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 73057FD11331AD2E001908EE;
remoteInfo = "RestKitJSONParser+JSONKit";
};
25D63963135184F1000879B1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 25BD43BD1340315800DBACDD;
remoteInfo = "RestKitXMLParser+Libxml";
remoteGlobalIDString = 25160D1614564E810060A5C5;
remoteInfo = RestKit;
};
25D63965135184F1000879B1 /* PBXContainerItemProxy */ = {
2534806814F941A900565CED /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 253A081412551D5300976E89;
remoteInfo = RestKitCoreData;
remoteGlobalIDString = 25160D2614564E820060A5C5;
remoteInfo = RestKitTests;
};
25D63967135184F1000879B1 /* PBXContainerItemProxy */ = {
2534806A14F941A900565CED /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 2523360511E79F090048F9B4;
remoteInfo = RestKitThree20;
remoteGlobalIDString = 25160E62145651060060A5C5;
remoteInfo = RestKitFramework;
};
25D63969135184F1000879B1 /* PBXContainerItemProxy */ = {
2534806C14F941A900565CED /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 3F6C39A510FE5C95008F47C5;
remoteInfo = UISpec;
remoteGlobalIDString = 25160E78145651060060A5C5;
remoteInfo = RestKitFrameworkTests;
};
25D6397013518504000879B1 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
proxyType = 1;
remoteGlobalIDString = 255B7588133BABBF00ED76AD;
remoteGlobalIDString = 25160D1514564E810060A5C5;
remoteInfo = RestKit;
};
25FB6D9F13E4848200F48969 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 25D63938135184F0000879B1 /* RestKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 20808DBD13DE8CDC000A156A;
remoteInfo = "RestKitJSONParser+NXJSON";
};
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -141,14 +88,10 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
25A8BA7A14F9458C005C7314 /* RestKit.framework in Frameworks */,
25D63983135185B6000879B1 /* SystemConfiguration.framework in Frameworks */,
25D639811351858A000879B1 /* AppKit.framework in Frameworks */,
25D6397F13518574000879B1 /* CoreData.framework in Frameworks */,
25D6397813518514000879B1 /* libRestKitCoreData.a in Frameworks */,
25D6397913518514000879B1 /* libRestKitJSONParserJSONKit.a in Frameworks */,
25D6397A13518514000879B1 /* libRestKitNetwork.a in Frameworks */,
25D6397B13518514000879B1 /* libRestKitObjectMapping.a in Frameworks */,
25D6397C13518514000879B1 /* libRestKitSupport.a in Frameworks */,
25D63919135184CE000879B1 /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -222,17 +165,10 @@
25D63939135184F0000879B1 /* Products */ = {
isa = PBXGroup;
children = (
25D63958135184F1000879B1 /* libRestKitNetwork.a */,
25D6395A135184F1000879B1 /* libRestKitObjectMapping.a */,
25D6395C135184F1000879B1 /* libRestKitSupport.a */,
25FB6DA013E4848200F48969 /* libRestKitJSONParserNXJSON.a */,
25D6395E135184F1000879B1 /* libRestKitJSONParserYAJL.a */,
25D63960135184F1000879B1 /* libRestKitJSONParserSBJSON.a */,
25D63962135184F1000879B1 /* libRestKitJSONParserJSONKit.a */,
25D63964135184F1000879B1 /* libRestKitXMLParserLibxml.a */,
25D63966135184F1000879B1 /* libRestKitCoreData.a */,
25D63968135184F1000879B1 /* libRestKitThree20.a */,
25D6396A135184F1000879B1 /* RestKitSpecs.app */,
2534806714F941A900565CED /* libRestKit.a */,
2534806914F941A900565CED /* RestKitTests.octest */,
2534806B14F941A900565CED /* RestKit.framework */,
2534806D14F941A900565CED /* RestKitFrameworkTests.octest */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -304,81 +240,32 @@
/* End PBXProject section */

/* Begin PBXReferenceProxy section */
25D63958135184F1000879B1 /* libRestKitNetwork.a */ = {
2534806714F941A900565CED /* libRestKit.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRestKitNetwork.a;
remoteRef = 25D63957135184F1000879B1 /* PBXContainerItemProxy */;
path = libRestKit.a;
remoteRef = 2534806614F941A900565CED /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
25D6395A135184F1000879B1 /* libRestKitObjectMapping.a */ = {
2534806914F941A900565CED /* RestKitTests.octest */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRestKitObjectMapping.a;
remoteRef = 25D63959135184F1000879B1 /* PBXContainerItemProxy */;
fileType = wrapper.cfbundle;
path = RestKitTests.octest;
remoteRef = 2534806814F941A900565CED /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
25D6395C135184F1000879B1 /* libRestKitSupport.a */ = {
2534806B14F941A900565CED /* RestKit.framework */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRestKitSupport.a;
remoteRef = 25D6395B135184F1000879B1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
25D6395E135184F1000879B1 /* libRestKitJSONParserYAJL.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRestKitJSONParserYAJL.a;
remoteRef = 25D6395D135184F1000879B1 /* PBXContainerItemProxy */;
fileType = wrapper.framework;
path = RestKit.framework;
remoteRef = 2534806A14F941A900565CED /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
25D63960135184F1000879B1 /* libRestKitJSONParserSBJSON.a */ = {
2534806D14F941A900565CED /* RestKitFrameworkTests.octest */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRestKitJSONParserSBJSON.a;
remoteRef = 25D6395F135184F1000879B1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
25D63962135184F1000879B1 /* libRestKitJSONParserJSONKit.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRestKitJSONParserJSONKit.a;
remoteRef = 25D63961135184F1000879B1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
25D63964135184F1000879B1 /* libRestKitXMLParserLibxml.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRestKitXMLParserLibxml.a;
remoteRef = 25D63963135184F1000879B1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
25D63966135184F1000879B1 /* libRestKitCoreData.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRestKitCoreData.a;
remoteRef = 25D63965135184F1000879B1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
25D63968135184F1000879B1 /* libRestKitThree20.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRestKitThree20.a;
remoteRef = 25D63967135184F1000879B1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
25D6396A135184F1000879B1 /* RestKitSpecs.app */ = {
isa = PBXReferenceProxy;
fileType = wrapper.application;
path = RestKitSpecs.app;
remoteRef = 25D63969135184F1000879B1 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
25FB6DA013E4848200F48969 /* libRestKitJSONParserNXJSON.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libRestKitJSONParserNXJSON.a;
remoteRef = 25FB6D9F13E4848200F48969 /* PBXContainerItemProxy */;
fileType = wrapper.cfbundle;
path = RestKitFrameworkTests.octest;
remoteRef = 2534806C14F941A900565CED /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
Expand Down

0 comments on commit 5e685d7

Please sign in to comment.