ios using blocks for assets library
-
14-02-2021 - |
Question
I need to use the assets library: i've found a snippets like this:
[library enumerateGroupsWithTypes:ALAssetsGroupAlbum
usingBlock:assetGroupEnumerator
failureBlock: ^(NSError *error) {
NSLog(@"Failure");
}];
and the compiler gives me the error like doesn't recognize the block ^.
is there a setting or something to enable the blocks in the project? thanks in advance
here is the complete error / code: https://skitch.com/ghiboz/grpyc/xcode
Paolo
Solution
My original answer -- Looks like you need to add the AssetsLibrary framework to your project.
My new answer -- for your asset enumerations, get rid of the "struct" keyword in your block declarations. You don't need them.
e.g.
void (^assetGroupEnumerator)(ALAssetsGroup *, BOOL *) = ^(ALAssetsGroup *group, BOOL *stop){
and
void (^assetEnumerator)(ALAsset *, NSUInteger, BOOL *) = ^(ALAsset * result, NSUInteger index, BOOL * stop)
OTHER TIPS
Are you using GCC instead of Clang? It has problems recognizing the signatures of blocks in many cases.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow