Frage

Hallo Ich rufe ALAssetsLibrary der

-enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:block failureBlock:failure;

dann in der Aufzählung Block i die Art der Gruppe vergleichen will zurückgegeben und es den jeweiligen Array hinzuzufügen. Ich habe versucht,

^( ALAssetsGroup *group, BOOL *stop )
{
    NSLog(@"Group %@", group );
    ALAssetGroupType assetType = (ALAssetGroupType)[group valueForProperty:ALAssetsGroupPropertyType];
    NSLog( @"Asset type %@", assetType );
    switch( assetType )
    {
        case ALAssetsGroupAplbum :
        NSLog( @"Found ALBUM" );
        [albums addObject:group];
        break;
    }
}

Die Anfangs log Spuren out "Gruppe ALAssetsGroup - Name: Photo Library, Typ: Album, Assets zählen: 177"

Das nächste Protokoll ist "Asset-Typ 2"

aber das dritte Protokoll nie genannt bekommen ist.

Alle Ideen, was ich falsch mache?

War es hilfreich?

Lösung

valueForProperty: returns an object. In the case of ALAssetsGroupPropertyType it returns an ALAssetGroupType constant wrapped in an NSNumber. (See docs here.)

So by casting to ALAssetGroupType you're using the object's memory address as your switch value. You need to get the underlying integer value of the NSNumber using intValue:

ALAssetGroupType assetType = 
 [[group valueForProperty:ALAssetsGroupPropertyType] intValue];
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top