Sinppet

The Asset Library is used here, so add import.

#import "AssetsLibrary/AssetsLibrary.h"

 

  CCSprite *playPhoto;

  CCLOG(@"Photo %@",dataManager.playerPhoto);

// check if the URL is an asset URL from the Photo Gallery.

    if(dataManager.playerPhoto != nil && [dataManager.playerPhoto rangeOfString:@"asset"].location !=NSNotFound)
    {
       
        NSURL *referenceURL = [[NSURL alloc] initWithString:dataManager.playerPhoto];
       
        ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
        [library assetForURL:referenceURL resultBlock:^(ALAsset *asset) {
            // code to handle the asset here

           
            // Let's create a sprite now that we have an image
            CCSprite *imagecc = [CCSprite spriteWithCGImage:[UIImage imageWithCGImage:[asset thumbnail]].CGImage key:@"playerPhoto"];
            [playerPhoto setTexture: imagecc.texture];

        } failureBlock:^(NSError *error) {
            // error handling
        }];
        [library release];
    }