If your block is asynchronous, you cannot set the return value before you return, because the program may not have completed the asynchronous task before the method completed. Some of the best solutions:
If you so wish, find a synchronous method that does the same job.
Now this is not the best choice, since your user interface will be blocked during the operation of the block.
Call the selector when this value is found, and invalidate the method itself.
Feel, try something like this:
-(void) findImageAtIndex:(NSUInteger)index target:(id)target foundSelector:(SEL)foundSEL { __block UIImage *image; [self.album enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:index] options:0 usingBlock: ^(ALAsset *result, NSUInteger index, BOOL *stop) {
Then you can call it like this:
...
source share