Skip to content

批量插入数组model的时候,下面的方法放在子线程就OK了 #1

@zjjzmw1

Description

@zjjzmw1
  • (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;
    }
    }];
    });
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions