I want to scan the Photo library with threads, when my app logic is ok I want to add the PHAsset
to finalarray
:
NSMutableArray <PHAsset *> *finalarray = [[NSMutableArray alloc] init];
for (NSMutableArray *photoArray in arrayOfArrays) {
dispatch_group_enter(aGroup);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
for (PHAsset *asset in photoArray) {
[[PHImageManager defaultManager] requestImageDataForAsset:asset
options:options
resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) {
//Make some logic
if (logic) {
[finalarray addObject:asset];
}
}];
}
dispatch_group_leave(aGroup);
});
}
arrayOfArrays
is array of array of PHAsset
.
My code works fine, but sometimes I get a SIGABRT
crash and I get this log in code console:
malloc: Incorrect checksum for freed object 0x1206d5968: probably modified after being freed.
Corrupt value: 0x100017580
malloc: *** set a breakpoint in malloc_error_break to debug
malloc: Incorrect checksum for freed object 0x1206d5968: probably modified after being freed.
Corrupt value: 0x100017580