- (void)fl_insertModelArr:(NSArray *)modelArr autoCloseDB:(BOOL)autoCloseDB complete:(void(^)(FLFMDBQueueManager *manager, BOOL flag))complete{ __block BOOL success = true; __weak typeof(self) weakSelf = self; FLDISPATCH_ASYNC_GLOBAL(^{ __strong typeof(weakSelf) strongSelf = weakSelf; //把任务包装到事务里 [FLCURRENTDBQUEUE inTransaction:^(FMDatabase *db, BOOL *rollback){ success = [strongSelf fl_insert:db modelArr:modelArr autoCloseDB:YES]; complete(strongSelf,success); //如果有错误 返回 if (!success){ *rollback = YES; return; } }]; }); }
__block BOOL success = true;
__weak typeof(self) weakSelf = self;
FLDISPATCH_ASYNC_GLOBAL(^{
__strong typeof(weakSelf) strongSelf = weakSelf;
//把任务包装到事务里
[FLCURRENTDBQUEUE inTransaction:^(FMDatabase *db, BOOL *rollback){
success = [strongSelf fl_insert:db modelArr:modelArr autoCloseDB:YES];
complete(strongSelf,success);
//如果有错误 返回
if (!success){
*rollback = YES;
return;
}
}];
});
}