0

I see many versions of this question, but I've looked through many of them and haven't found something explaining my problem yet. I hope this isn't a repeat question.

I am simply trying to initialize an AVAssetWriter with this init! method defined in the documentation:

init!(URL outputURL: NSURL!,
 fileType outputFileType: String!,
    error outError: NSErrorPointer)

So I've written the following code in my playground:

var err : NSError? = nil
var outputPath = "\(NSTemporaryDirectory())mypath.mov"

var url = NSURL(fileURLWithPath: outputPath)
var fileManager = NSFileManager.defaultManager()
println("The putput path is \(outputPath)")
if(fileManager.fileExistsAtPath(outputPath))
{
   fileManager.removeItemAtPath(outputPath, error: &err)
   println(outputPath)
   if(err != nil)
   {
      println("Error: \(err?.localizedDescription)")
   }
}
var writeInitErr : NSError? = nil
var assetWriter = AVAssetWriter(URL: url, fileType: AVMediaTypeVideo, error: writeInitErr)

However, the last line throws the error "Extra argument 'URL' in call". None of the solutions I found in other questions about this error seem to apply here. Am I passing the wrong type to the parameter? Am I misunderstanding the use of the initializer?

1 Answers1

1

Well, as is often the case, I figured out the answer minutes after asking the question.

The problem is actually with the "error: writeInitError" parameter, which should be

"error: &writeInitError"

Apparently the xcode error reporting is buggy, and was reporting a problem with the URL parameter instead. Fixing the error parameter solved the problem.

I suppose until the error reporting is improved, "Extra argument in call" translates to "Something is wrong with one of your parameters".