I'm trying to get all the albums names. here is what I do.
The method [group valueForKey:ALAssetsGroupPropertyName]
crashes
ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init];
[assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos | ALAssetsGroupAlbum
usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (nil != group)
{
NSLog(@"name %@",[group valueForKey:ALAssetsGroupPropertyName]);
}
*stop = NO;
} failureBlock:^(NSError *error) {
NSLog(@"error: %@", error);
}];
I really don't know why it crashes, if someone knows, I'll really appreciate some help !
Here is the crash log :
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ALAssetsGroup 0x17801ff90> valueForUndefinedKey:]: this class is not key value coding-compliant for the key ALAssetsGroupPropertyName.`
You are calling the wrong method. Change this:
NSLog(@"name %@",[group valueForKey:ALAssetsGroupPropertyName]);
to:
NSLog(@"name %@",[group valueForProperty:ALAssetsGroupPropertyName]);