- Xcodeの7
- スウィフト2
- のObjective C
私はいくつかのObjective Cのコードを変更している、と私はすべてのObjective Cの構文を知りません。 Objective Cのではは交換UISaveVideoAtPathToSavedPhotosAlbum @selector videoSaved機能
NSString *tempFilePath = [downloadURL path];
NSError * error = nil;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder
NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/Videos"];
//NSString *newPath = [[tempFilePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:AvailableVideos[0]];
NSString *newPath = [dataPath stringByAppendingPathComponent:AvailableVideos[0]];
NSFileManager *fileManager = [NSFileManager defaultManager];
if (![fileManager fileExistsAtPath:dataPath])
[fileManager createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error]; //Create folder
//copying temp video to Documents Directory
if ([fileManager fileExistsAtPath:newPath] == YES)
[fileManager removeItemAtPath:newPath error:&error];
[fileManager copyItemAtPath:tempFilePath toPath:newPath error:&error];
:私のアプリのデータコンテナドキュメントディレクトリに映像を保存しているコードで
if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(newPath))
// Copy it to the camera roll.
UISaveVideoAtPathToSavedPhotosAlbum(newPath, self, @selector(videoSaved:didFinishSavingWithError:contextInfo:), (__bridge void *)(AvailableVideos[0]));
else
{
[self ErrorOnDownloadOrSave];
return;
}
:私はカメラロールにビデオを保存して、次のコードを交換しました「videoSaved」イベントが完了したときに呼び出されObjective Cの「機能」があるiOSのカメラロールに保存されているコード:
-(void)videoSaved:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo{
//implementation
}
私が呼び出す方法を把握する必要がありこのコードの後に、この「機能」、「videoSaved」:
//copying temp video to Documents Directory
if ([fileManager fileExistsAtPath:newPath] == YES)
[fileManager removeItemAtPath:newPath error:&error];
[fileManager copyItemAtPath:tempFilePath toPath:newPath error:&error];
私はvideoSaved
機能がUISaveVideoAtPathToSavedPhotosAlbum
のための特別な署名であるが、私は、私は新しい関数を記述するのか分からないのObjective Cでちょうどそう不慣れだ実現私が呼び出すことができ、私のエラーオブジェクトを渡し、videoSaved
の実装を維持します。