错误:可选类型'NSOperationQueue?'的值没有打开;你有人使用'!'要么 '?'?

时间:2015-10-27 18:33:22

标签: swift nsoperationqueue

所以,我试图从加速计传感器获取数据,但即使我尝试了'!',我仍然会收到此错误。和'?'和'如果让'。我无法想到尝试其他任何东西,而奇怪的想法是相同的代码在我得到它的youtube教程上工作。 这是代码:

$('#programme').typeahead({
    remote: {
        url: 'typeahead.php?programme&type=1&school_name=',
        replace: function (url, query) {
            // This 'if' statement is only necessary if there's a chance that the input might not exist.
            if ($('#school').val()) {
                url += encodeURIComponent(('#school').val());
            }
            return url;
        }
    },
    cache: false,
    limit: 10
});

真的很感激任何帮助..

1 个答案:

答案 0 :(得分:0)

它对我有用

let motionManager = CMMotionManager()
if let queue = NSOperationQueue.currentQueue() {
    motionManager.startAccelerometerUpdatesToQueue(queue) { (data, error) -> Void in }
}
相关问题