Skip to content

Instantly share code, notes, and snippets.

@matzew
Created August 23, 2012 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matzew/3437960 to your computer and use it in GitHub Desktop.
Save matzew/3437960 to your computer and use it in GitHub Desktop.
Reading from a pipe

A QUICK sample/snippet on reading from a pipe.....

The API

...
/**
 * Reads all the data from the underlying server connection.
 *
 * @param success A block object to be executed when the request operation finishes successfully.
 * This block has no return value and takes one argument: The object created from the response
 * data of request.
 *
 * @param failure A block object to be executed when the request operation finishes unsuccessfully,
 * or that finishes successfully, but encountered an error while parsing the resonse data.
 * This block has no return value and takes one argument: The `NSError` object describing
 * the network or parsing error that occurred.
 */
 -(void) read:(void (^)(id responseObject))success
      failure:(void (^)(NSError *error))failure;

...

Usage of the API

...
id<AGPipe> projectPipe = // get a reference to a pipe....
[projectPipe read:^(id responseObject) {
    // get's invoked when the response returns....
    // do something with the data.... or just log it to the console.....
    NSLog(@"Projects: %@", responseObject);
} failure:^(NSError *error) {
    // do some proper error handling, if needed/desired...
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment