Я загружаю видео благодаря downloadTaskWithURL, и я сохраняю его в своей галерее с помощью этого кода:
func saveVideoBis(fileStringURL:String){
print("saveVideoBis");
let url = NSURL(string: fileStringURL);
(NSURLSession.sharedSession().downloadTaskWithURL(url!) { (location:NSURL?, r:NSURLResponse?, e:NSError?) -> Void in
let mgr = NSFileManager.defaultManager()
let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0];
print(documentsPath);
let destination = NSURL(string: NSString(format: "%@/%@", documentsPath, url!.lastPathComponent!) as String);
print(destination);
try? mgr.moveItemAtPath(location!.path!, toPath: destination!.path!)
PHPhotoLibrary.requestAuthorization({ (a:PHAuthorizationStatus) -> Void in
PHPhotoLibrary.sharedPhotoLibrary().performChanges({
PHAssetChangeRequest.creationRequestForAssetFromVideoAtFileURL(destination!);
}) { completed, error in
if completed {
print(error);
print("Video is saved!");
self.sendNotification();
}
}
})
}).resume()
}
Он отлично работает на моем симуляторе, но на моем iPad видео не сохраняется, даже если появляется print("Video is saved!");
.
Вы знаете, почему?
У меня также есть это сообщение, появившееся на моей консоли
Невозможно создать данные из файла (null)