我在后台线程上调用一个方法..写在下面
imageRef = assetLbraryImp.defaultRepresentation.fullResolutionImage;
[self saveBigImageFull:imageRef withName:mediafileName addToAlbum:isFromCamera];
-(void)saveBigImageFull:(CGImageRef)bigImage withName:(NSString*)imageName addToAlbum: (BOOL)addToAlbum{
bigImageFulldata = [NSArray arrayWithObjects: imageName, [NSNumber numberWithBool:addToAlbum], nil];
[self saveBigImage:bigImageFulldata :bigImage];
}
-(void)saveBigImage:(id)data:(CGImageRef)imageRefere{
_iName = (NSString *)[data objectAtIndex:0] ;
bigImagefileName = [[NSString alloc]initWithFormat:@"%@.jpg", _iName] ;
bigImageFilepath = [photoPath stringByAppendingPathComponent:bigImagefileName] ;
[self savePhotoBig:imageRefere toPath:bigImageFilepath];
}
-(void)savePhoto:(CGImageRef)photo toPath:(NSString *)path{
image = [UIImage imageWithCGImage:photo];
imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:path atomically:NO];
if(photo)
CFRelease(photo);
}
但是由于 CFRelease 导致应用程序崩溃。当我删除 CFRelease 时,代码工作正常。如果保存 100 张图像,则保存 100 张图像。即使在最终应用程序崩溃保存后。应用程序在进程结束时崩溃,而不是介于两者之间。
任何想法?