Not used, so we only need the error.
No longer used as everything is through the class method now.
Still returns an id, but this can be either an NSArray, an NSNumber with YES or NO for boolean handling, or an NSError. - If it's an array, json was received and parsed as expected. - If it's an NSNumber YES, that's a successful call to a method that expects a No Content response. - If it's an NSNumber NO, that's a successful call to a method that returns an expected 404. - If it's an NSError, it's either a connection error, an HTTP error other than the above, or a parser error. NSError instance can be inspected to determine which. This all enables us to return e.g. a BOOL from a call to UAGE. This is useful in situations where Github will return no data, when calling e.g. -follows:completion:. This can now return a simple YES or NO. Error handling is also significantly improved, in that it now exists.
Missed in the first pass.
Removed old commented-out class method for instantiation. Re-added dateElement handling. Added error handling - +parse:error: now takes a pointer to an error that gets filled if either the JSON deserialization fails or Github returns an error in JSON.
Not even sure where - (id)followedBy:(NSString *)user completion:(id(^)(id obj))successBlock_; came from.
Callback gets called whether the call succeeds or not, so completion is more semantically accurate.
Now we're using blocks, we can get rid of the delegates we were using previously, namely UAGithubEngineDelegate and UAGithubJSONParserDelegate. Also allows us to shave method names, e.g. + (id)parseJSON:(NSData *)theJSON delegate:(id)theDelegate connectionIdentifier:(NSString *)theIdentifier requestType:(UAGithubRequestType)reqType responseType:(UAGithubResponseType)respType; becomes + (id)parseJSON:(NSData *)theJSON;.
- Engine methods now take an extra parameter: successBlock. This block takes an id and returns an id. - -sendRequest:… methods now return an id instead of an NSString. This id is the JSON returned from the API, parsed for ObjC consumption. - All calls to -sendRequest:… are wrapped in a call to successBlock(). - When calling engine methods, we populate the successBlock parameter with what we want to be executed on successful completion of the call. - All the above is in place of using delegation. May (should?) eventually lead to the fiery death of UAGithubEngineDelegate.
Ensure any completion-blocks execute *after* the connection returns instead of trying to do it beforehand.
UAGE now uses blocks throughout the main engine file. URLConnections are fired off using a new class method on UAGithubURLConnection, which takes a success/failure block pair. The success block calls a new class method on UAGithubJSONParser, which also takes a success/failure block pair. All remaining methods that were delegate calls are now called or handled by the core -sendRequest:… method.