Created
May 13, 2014 11:09
-
-
Save imoldman/a9a804917a7fd12b0142 to your computer and use it in GitHub Desktop.
Auto rollback version for - [FMDatabase inSavePoint]
This file contains hidden or 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
@interface FMDatabase (AutoRollback) | |
@end | |
@implementation FMDatabase (AutoRollback) | |
- (NSError*)inAutoRollbackSavePoint:(NSError* (^)())block | |
{ | |
__block NSError* internalError = nil; | |
NSError* error = [self inSavePoint:^(BOOL* rollback) { | |
internalError = block(); | |
if (internalError != nil) { | |
*rollback = YES; | |
} | |
}]; | |
return internalError != nil ? internalError : error; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment