I have this code to record video with AVFoundation but I don't know how convert to Swift
- (void)startRecording
{
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"yyyy-MM-dd-HH-mm-ss"];
NSString* dateTimePrefix = [formatter stringFromDate:[NSDate date]];
int fileNamePostfix = 0;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath = nil;
do
filePath =[NSString stringWithFormat:@"/%@/%@-%i.mp4", documentsDirectory, dateTimePrefix, fileNamePostfix++];
while ([[NSFileManager defaultManager] fileExistsAtPath:filePath]);
NSURL *fileURL = [NSURL URLWithString:[@"file://" stringByAppendingString:filePath]];
[self.fileOutput startRecordingToOutputFileURL:fileURL recordingDelegate:self];
}
I don't know how work with this paths in Swift..
Thanks!!