Objective c 无法停止NSAssetsLibrary
它运行良好,但不会停止Objective c 无法停止NSAssetsLibrary,objective-c,Objective C,它运行良好,但不会停止 [group enumerateAssetsAtIndexes:set options:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { CGImageRef imageRef = result.defaultRepresentation.fullResolutionImage;
[group enumerateAssetsAtIndexes:set options:NSEnumerationReverse usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop)
{
CGImageRef imageRef = result.defaultRepresentation.fullResolutionImage;
UIImage *toSend=[UIImage imageWithCGImage:imageRef];
NSLog(@"INDEXX:%d",index); //logged after i stop !
for(int c=0;c<[selectedButtonsTags count];c++)
if((numberOfAssets-1)-index ==[[selectedButtonsTags objectAtIndex:c] integerValue])
{[savedImages addObject:toSend]; NSLog(@"IMAGE IS:%@ index:%d",toSend,index); }
if(index==numberOfAssets-max-1 )
{ NSLog(@"OUT!"); //it DO log this !
*stop=YES;
}
}];
[组EnumerateAssetStatIndex:设置选项:NSEnumerationReverse usingBlock:^(ALAsset*结果,NSUTEGER索引,布尔*停止)
{
CGImageRef imageRef=result.defaultRepresentation.fullResolutionImage;
UIImage*toSend=[UIImage imageWithCGImage:imageRef];
NSLog(@“INDEXX:%d”,index);//在我停止后记录!
对于(intc=0;c,我开始了解它是如何工作的。
如果我在阻止他之前做了块中的事情,他会继续枚举,当我阻止他时,他已经开始下一个索引
所以你必须在障碍开始时阻止他,然后再做更多的事情
if(index==numberOfAssets-max-1 )
*stop=YES;
现在在街区的起点,他停了下来。
如果以后需要调用函数,可以将相同的条件放在以后的函数中。
但是,正如我所说,您必须首先阻止他。您必须检查块中的result==nil
或index==NSNotFound
,请参阅以了解非常类似的问题。