Baymax0 / BMChineseSort

BMChineseSort是一个为模型、字典、字符串数组根据特定中文属性基于tableview分组优化的工具类,基于异步、多线程降低排序时间。
Other
192 stars 23 forks source link

Semaphore object deallocated while in use Abort Cause 1 报错 #16

Open shaobinbin0621 opened 5 years ago

shaobinbin0621 commented 5 years ago

谷歌了下, ` semaphore = dispatch_semaphore_create(1);

//异步执行
dispatch_async(dispatch_get_global_queue(0, 0), ^{
    //将数据 转换为 BMChineseSortModel
    NSMutableArray *sortModelArray = [NSMutableArray arrayWithCapacity:0];
    [objectArray enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        BMChineseSortModel *model = [self getModelWithObj:obj key:key];
        if (model) {
            //对 数组的插入操作 上锁
            dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
                [sortModelArray addObject:model];
            dispatch_semaphore_signal(semaphore);
        }
    }];`

系统判断sema是否被使用的标志为sema被销毁时的值是否与初始化的值相同

zhoumingwu commented 1 year ago

解决了吗,我也遇到相同问题