Created
August 9, 2010 02:18
-
-
Save wkiefer/514835 to your computer and use it in GitHub Desktop.
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
// This is why I love blocks. | |
// I have an async protocol to add/write a file to disk. Here's the full implementation of one call. | |
// It's so much easier than managing delegates, threads, callback objects and selectors. | |
- (void)addStoreItemWithType:(TAStoreItemType)type | |
identifier:(NSString *)identifier | |
properties:(NSDictionary *)properties | |
completionBlock:(void (^)(BOOL success, NSError *error))completionBlock { | |
dispatch_async(fileio_queue_, | |
^(void) { | |
NSError *error = nil; | |
BOOL success = [FileStore writeProperties:properties | |
toURL:[FileStore _urlForType:type identifier:identifier] | |
error:&error]; | |
dispatch_async(dispatch_get_main_queue(), ^(void) { completionBlock(success, error); }); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment