'ALAssetsLibraryAssetForURLResultBlock' is deprecated

Viewed 525

I am just a beginner here, creating an iOS app but its showing me following error:

'ALAsset' is deprecated: first deprecated in iOS 9.0 - Use PHAsset from the Photos framework instead

'ALAssetsLibraryAssetForURLResultBlock' is deprecated: first deprecated in iOS 9.0 - Use fetchAssetsWithLocalIdentifiers:options: on PHAsset to fetch assets by local identifier (or to lookup PHAssets by a previously known ALAssetPropertyAssetURL use fetchAssetsWithALAssetURLs:options:) from the Photos framework instead

if ([[url absoluteString] hasPrefix:kCDVAssetsLibraryPrefixes]) {
    ALAssetsLibraryAssetForURLResultBlock resultBlock = ^(ALAsset* asset) {
        if (asset) {
            ALAssetRepresentation* assetRepresentation = [asset defaultRepresentation];
            NSString* MIMEType = (__bridge_transfer NSString*)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)[assetRepresentation UTI], kUTTagClassMIMEType);
            Byte* buffer = (Byte*)malloc((unsigned long)[assetRepresentation size]);
            NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:0.0 length:(NSUInteger)[assetRepresentation size] error:nil];
            NSData* data = [NSData dataWithBytesNoCopy:buffer length:bufferSize freeWhenDone:YES];
            [self sendResponseWithResponseCode:200 data:data mimeType:MIMEType];
        }
0 Answers
Related