Created
September 20, 2012 19:25
-
-
Save matzew/3757841 to your computer and use it in GitHub Desktop.
Mixing Pipe and data storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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