Skip to content

Instantly share code, notes, and snippets.

@matzew
Created September 20, 2012 19:25
Show Gist options
  • Save matzew/3757841 to your computer and use it in GitHub Desktop.
Save matzew/3757841 to your computer and use it in GitHub Desktop.
Mixing Pipe and data storage
// Get SOMEHOW... a reference to a pipe
id<AGPipe> tasksPipe = ...
// create new store:
AGDataManager* mgr = [[AGDataManager alloc] init];
id<AGStore> tasksStore = [mgr add:@"tasks"];
...
// later in the program....
....
// Let's read data from the server connection (aka pipe)...
[tasksPipe read:^(id responseObject) {
// if reading from the server was successful, we now
// store the values from the pipe in our 'data store':
[tasksStore save:responseObject success:^(id object) {
// issue some 'YES, could stash the data away...'...
} failure:^(NSError *error) {
// log the error....
}];
} failure:^(NSError *error) {
// when an error occurs... at least log it to the console..
NSLog(@"Read: An error occured! \n%@", error);
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment