我在项目中使用Github项目MMSCameraViewController,并且自从最近的Xcode 8.3更新以来,编译器抛出了错误:
/MMSCameraViewController/Classes/MMSCameraViewController.swift:448:42:输入' [Any] !!'不符合协议'序列'
<script>
window.parent.$('.close').click(function () {
var thisObj = this;
if (!feedbackLoaded) {
$('#openFeedback').click();
feedbackLoaded = true;
$('#feedbackForm .close').click(function () {
window.parent.$.magnificPopup.proto.close.call(thisObj);
});
return false;
} else {
window.parent.$.magnificPopup.proto.close.call(thisObj);
}
});
</script>
我在其他帖子中搜索了最近出现在这里的类型 - 任意序列帖子,但这些都没有帮助我(而且我是Swift的新手)。知道如何解决这个问题吗?
非常感谢!
马丁
答案 0 :(得分:1)
因为AnyObject不是你想要的,所以错误很明显。
for port in (connection as! AVCaptureConnection).inputPorts {
if (port as! AVCaptureInputPort).mediaType == AVMediaTypeVideo {
videoConnection = connection as! AVCaptureConnection
break connectionloop
}
}
库应该遍历每个端口,因此AnyObject没有任何
答案 1 :(得分:1)
我假设您的连接是AVCaptureConnection类,因此您不应该将其强制转换为AnyObject:
// Change first line to this
for port in connection.inputPorts {
// Also to make it more secure (and avoid force casting)
if let port = port as? AVCaptureInputPort,
port.mediaType == AVMediaTypeVideo {
// You can delete force casting also here
videoConnection = connection
break connectionloop
}
}