0
votes

I am working on an iOS app, and I just switched to Swift 3.0, so now I have a lot of errors in my code, and I'm not sure how to fix some of them.

1) Error "Argument labels '(fileURLwithPathComponents:)' do not match any available overloads" on the second line of this snippet:

let pathArray = [dirPath, recordingName]
let filePath = URL(fileURLwithPathComponents: pathArray)

2) Error "Cannot convert value of type '(CMAccelerometerData?,NSError?)->() to expected argument type 'CMAccelermeterHandler' (aka ('Optional, Optional)->()')"

  motionManager.startAccelerometerUpdates(to: OperationQueue.main) {
        [weak self] (data: CMAccelerometerData?, error: NSError?) in self!.label.text = "started tracking"
1
Some of the syntax has changed after the move to Swift 3. You can find the correct syntax in Apple's documentation. - koen
developer.apple.com/reference/foundation/nsurl/1414206-fileurl for the first one. Signature changed for the method. - Larme
Thanks @Larme, that worked perfectly for #1 --> let filePath = NSURL.fileURL(withPathComponents: pathArray) - Maria
I would encourage you to try to find the new syntax for the second error yourself. You will make many more trips to the documentation as an developer. - koen
thanks @Koen! I went through many of them, and these were the only two I didn't quite get. But I also just found the solution to my second one -- should be just Error not NSError - Maria

1 Answers

0
votes

Thanks to @Koen and @Larme, I found the solution to both of these:

1) let filePath = NSURL.fileURL(withPathComponents: pathArray)

2) should be just "Error" not "NSError"