Hi All
Just try to save remote video but all time get error: Error Domain=NSCocoaErrorDomain Code=-1 "(null)"
Xcode 7.0.1.
iPhone 4s with iOS 9.0.2
[[[NSURLSession sharedSession] downloadTaskWithURL:[NSURL URLWithString:@"<url to file>"] completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) {
[PHPhotoLibrary requestAuthorization:^( PHAuthorizationStatus status ) {
if ( status == PHAuthorizationStatusAuthorized ) {
// Save the movie file to the photo library and cleanup.
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
// In iOS 9 and later, it's possible to move the file into the photo library without duplicating the file data.
// This avoids using double the disk space during save, which can make a difference on devices with limited free disk space.
if ( [PHAssetResourceCreationOptions class] ) {
PHAssetResourceCreationOptions *options = [[PHAssetResourceCreationOptions alloc] init];
options.shouldMoveFile = YES;
PHAssetCreationRequest *changeRequest = [PHAssetCreationRequest creationRequestForAsset];
[changeRequest addResourceWithType:PHAssetResourceTypeVideo fileURL:location options:options];
}
else {
[PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:location];
}
} completionHandler:^( BOOL success, NSError *error ) {
if ( ! success ) {
NSLog( @"Could not save movie to photo library: %@", error );
}
}];
}
else {
}
}];
}] resume];Could someone help me? What did I do wrong?