I am trying to translate the following code to Swift 2.
manager.startAccelerometerUpdatesToQueue(NSOperationQueue.mainQueue()) { [weak self] (data: CMAccelerometerData!, error: NSError!) in
self!.outputAccData(data.acceleration)
}
But this gives me the following error.
Type of expression is ambiguous without more context
Does anyone know why this is happening?
This is one of those problems that can be solved by retyping the code from scratch. It appears that the second parameter to
startAccelerometerUpdatesToQueue()
is now an object of type(CMAccelerometerData?, NSError?) -> Void
instead of(CMAccelerometerData!, NSError!) -> Void
. You just need to rewrite your call to reflect this.