Swift 3.0如何使用startDeviceMotionUpdates(to:withHandler)?

Moh*_*dal 4 core-motion scenekit swift3 ios10 xcode8

Swift 3.0与Xcode 8.0一起发布,显然已经发生了很多变化.我对swift中的新语法非常不熟悉.有人可以帮我吗?我想弄清楚里面发生了什么

motionManager.startDeviceMotionUpdates(
        to: OperationQueue.current()!,
        withHandler: )
Run Code Online (Sandbox Code Playgroud)

在"withHandler:"之后

我试图让我的SceneKit程序能够利用加速度计来确定SCNNode平台的方向.我对swift也很新(在Swift编程大约5天)所以如果有一些基本的东西搞砸了,请告诉我.

Bis*_*ung 6

参考

您必须传递符合CMDeviceMotionHandler类型的块.

 motionManager.startDeviceMotionUpdates(to: OperationQueue.current()!, withHandler:{
                deviceManager, error in
                //Do stuffs with deviceManager or with error

            })
Run Code Online (Sandbox Code Playgroud)