web-dev-qa-db-ja.com

ALAssetsLibraryのようなPHPhotoLibraryの使い方

IOS9の場合、ALAssetsLibraryは非推奨です。では、PHPPhotoLibraryではなくALAssetsとして変更するにはどうすればよいですか?

if (RecordedSuccessfully && recording == NO) {
    //----- RECORDED SUCESSFULLY -----
    NSLog(@"didFinishRecordingToOutputFileAtURL - success");
    ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
    if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:outputFileURL])
    {
        [library writeVideoAtPathToSavedPhotosAlbum:outputFileURL
                                    completionBlock:^(NSURL *assetURL, NSError *error)
         {
             if (error)
             {

             }
         }];
    }

//これを試しましたが、機能しませんでした

[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{

        PHAssetChangeRequest* createAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:outputFileURL];

        NSParameterAssert(createAssetRequest);
    }
                                      completionHandler:^(BOOL success, NSError *error) {}];
    }
}
12
dicle
// Save to the album
   __block PHObjectPlaceholder *placeholder;

    [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
        PHAssetChangeRequest* createAssetRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:outputFileURL];
        placeholder = [createAssetRequest placeholderForCreatedAsset];

    } completionHandler:^(BOOL success, NSError *error) {
        if (success)
        {
           NSLog(@"didFinishRecordingToOutputFileAtURL - success for ios9");
        }
        else
        {
            NSLog(@"%@", error);
        }
    }];
19
Dicle