I am making an app that takes pictures with AVFoundation and I want to save them to a custom album that I can then query and show in my app. (I\'d prefer to not have them in
I improved on @ricardopereira and @ColossalChris code. Added video to the extension, and added another extension on top of PHAsset to get rid of the compilation errors. Works in Swift 2.1.
Sample usage:
#import "Yourtargetname-Swift.h"//important!
NSURL *videoURL = [[NSURL alloc] initFileURLWithPath:PATH_TO_VIDEO];
[PHPhotoLibrary saveVideo:videoURL albumName:@"my album" completion:^(PHAsset * asset) {
NSLog(@"success");
NSLog(@"asset%lu",(unsigned long)asset.pixelWidth);
}];
Import both swift files: https://github.com/kv2/PHPhotoLibrary-PhotoAsset.swift
It is usable in objective-c as long as you import the swift header for your target (see the ViewController.m file).