asset-library:// にあるビデオをアプリケーション内のディレクトリ(NSDocumentDirectory)とかにコピーしたいこととかありますよね。この場合、NSFileManagerではダメです。
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:assetURL resultBlock:^(ALAsset *asset) {
ALAssetRepresentation *rep = [asset defaultRepresentation];
Byte *buffer = (Byte*)malloc(rep.size);
NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:rep.size error:nil];
NSData *data = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];
[data writeToURL:outputURL atomically:YES];
} failureBlock:^(NSError *error) {
NSLog(@"%@", [error description]);
}];
画像の場合はこんな感じかな?
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
[library assetForURL:assetURL resultBlock:^(ALAsset *asset) {
ALAssetRepresentation *rep = [asset defaultRepresentation];
CGImageRef cgImg = [rep fullResolutionImage];
UIImage *img = [UIImage imageWithCGImage:cgImg];
NSData *data = UIImagePNGRepresentation(img);
[data writeToURL:outputURL atomically:YES];
} failureBlock:^(NSError *error) {
NSLog(@"%@", [error description]);
}];