0
如何突破ALAssetsLibrary enumerateAssets方法中使用布爾值集合的枚舉。我可以跳出循環嗎?中斷圖片的迭代ALAssetsLibrary
CODE:
[self.library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
@try {
if(group != nil) {
@autoreleasepool {
int newNumberOfPhotos = [group numberOfAssets];
if (self.numberOfPhotosInSavedPhotos < newNumberOfPhotos) {
//only new photos
NSRange range = NSMakeRange(self.numberOfPhotosInSavedPhotos, newNumberOfPhotos-self.numberOfPhotosInSavedPhotos);
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndexesInRange:range];
[group enumerateAssetsAtIndexes:indexSet options:0 usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
@autoreleasepool {
if(someCondition) {
//get out of the enumeration block (that is, exit the method) or go to complete block
}
NSString *assetType = [result valueForProperty:ALAssetPropertyType];
}
} ];
}
}
} else {
//enumeration ended
}
}
@catch (NSException *e) {
NSLog(@"exception streaming: %@", [e description]);
}
}failureBlock:^(NSError *error){
NSLog(@"Error retrieving albums stream: %@", [error description]);
if (error.code==-3312 || error.code==-3311) {
}
}];
可以請你!更具體地說,你陷入困境並需要幫助?發佈相關代碼將有助於理解您的問題。 – swiftBoy