我已编写此代码来录制视频,并希望将filePath保存到文档目录,我该怎么做?
func startRecording() {
var currentDateTime = NSDate()
var formatter = NSDateFormatter()
formatter.dateFormat = "MM-dd-yyyy, hh:mm:ss a"
var recordingName = formatter.stringFromDate(currentDateTime) + ".mp4"
var pathArray = [dirPath, recordingName]
let filePath = NSURL.fileURLWithPathComponents(pathArray)
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera) {
videoRecorder = UIImagePickerController()
videoRecorder.delegate = self
videoRecorder.sourceType = UIImagePickerControllerSourceType.Camera
videoRecorder.mediaTypes = [kUTTypeMovie]
videoRecorder.videoMaximumDuration = 3600.0
videoRecorder.startVideoCapture()
}
}
答案 0 :(得分:1)
之前我做过这个,你可以使用NSFileHandle来做到这一点
NSFileHandle(forWritingToURL:filePath,error:nil)
它对我有用。