How to convert this code to Swift for saving video? -
How to convert this code to Swift for saving video? -
i have code save video:
(void)saverecordedfile:(nsurl *)recordedfile {
[svprogresshud showwithstatus:@"saving..." masktype:svprogresshudmasktypegradient];
dispatch_queue_t queue = dispatch_get_global_queue(dispatch_queue_priority_default, 0); dispatch_async(queue, ^{
alassetslibrary *assetlibrary = [[alassetslibrary alloc] init]; [assetlibrary writevideoatpathtosavedphotosalbum:recordedfile completionblock: ^(nsurl *asseturl, nserror *error) { dispatch_async(dispatch_get_main_queue(), ^{ [svprogresshud dismiss]; nsstring *title; nsstring *message; if (error != nil) { title = @"failed save video"; message = [error localizeddescription]; } else { title = @"saved!"; message = nil; } uialertview *alert = [[uialertview alloc] initwithtitle:title message:message delegate:nil cancelbuttontitle:@"ok" otherbuttontitles:nil]; [alert show]; }); }];
}); }
i want convert swift, , don't know how alter lines:
alassetslibrary *assetlibrary = [[alassetslibrary alloc] init]; [assetlibrary writevideoatpathtosavedphotosalbum:recordedfile completionblock: ^(nsurl *asseturl, nserror *error)
how can convert completionblock ^(nsurl *asseturl, nserror *error) swift?
thanks!!
i solved with:
typealias alassetslibrarywritevideocompletionblock = (nsurl!, nserror!) -> void var finish : alassetslibrarywritevideocompletionblock = {reason in println(reason)} library.writevideoatpathtosavedphotosalbum( fileurl, complete)
thanks!
video swift avfoundation ios8
Comments
Post a Comment