BMChineseSort
BMChineseSort copied to clipboard
Semaphore object deallocated while in use Abort Cause 1 报错
谷歌了下, ` 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被销毁时的值是否与初始化的值相同
解决了吗,我也遇到相同问题