forcedotcom/SalesforceMobileSDK-iOS — pull request #24 by jhersh (2012-01-03 22:43:58+00:00)
Title: Block-based interface to the iOS SDK's REST API.

I wrote a new block-based interface for issuing and receiving responses to REST requests sent through the iOS SDK. It's contained within `SFVRestAsync.h` and `SFVRestAsync.m`. This commit also includes `SynthesizeSingleton.h`, a utility class that makes a singleton out of `SFVRestAsync` with just one line.

`SFVRestAsync` is a singleton so that it can cache requests you send it, the idea being that you may issue numerous REST requests all at once to different endpoints that may all return at different times, some erroring (or not), etc. With this cache, `SFVRestAsync` knows which failure and complete blocks to use for each submitted REST request.

The methods exposed through `SFVRestAsync` should follow exactly the methods defined in `SFRestAPI` with one exception: my version of `requestForRetrieveWithObjectType:objectId:fieldList:` takes an `NSArray` instead of a comma-separated `NSString` for the `fieldList`. My version performs the comma-separation automatically and also eliminates duplicate fields specified in the array.

An example of just how easy it is to use these block methods to, say, request REST API versions:

```[[SFVRestAsync sharedSFVRestAsync] performRequestForVersionsWithFailBlock:nil
completeBlock:^(NSDictionary *results) {
NSLog(@"VERSIONS %@", results);
}];
```