问题描述
我在 Xcode 8 中将我的 (macOS) 项目转换为 Swift 3,并且我在 swift 类中实现的几个委托方法收到以下警告:
I converted my (macOS) project to Swift 3 in Xcode 8 and I get the following warnings with several delegate methods I implement in swift classes:
Instance method 'someMethod' nearly matches optional requirement of protocol 'protocolName'
我在几个 NSApplicationDelegate 方法中得到了这个,比如 applicationDidFinishLaunching
和 applicationDidBecomeActive
:
I get this for several NSApplicationDelegate methods like applicationDidFinishLaunching
and applicationDidBecomeActive
:
但也适用于 tableViewSelectionDidChange
的实现:
But also for implementations of tableViewSelectionDidChange
:
我使用代码完成来插入方法签名,并尝试从 SDK 头文件中复制它们以排除拼写错误.警告不会消失,方法也不会被调用.
I used code completion to insert the method signatures and also tried copying them from the SDK-headers to rule out typos. The warnings just don't disappear and the methods are never called.
我在这里遗漏了什么?
推荐答案
我们就此问题联系了 Apple 开发人员技术支持 (DTS).他们回答说这是 Xcode 8 中的一个错误.
We contacted Apple Developer Technical Support (DTS) with this issue.They replied that this is a bug in Xcode 8.
我们提交了错误报告,希望能快速更新.(Apple 错误报告 ID:28315920).
We submitted a bug report and hope for a quick update. (Apple Bug Report ID: 28315920).
如果您遇到类似问题,也请提交错误报告(指的是我们的)所以苹果工程师看到的不是一个案例.
If you experience a similar issue, please also file a bug report (referring to ours) so the Apple engineers see its not a single case.
Xcode ≥ 8.1 的更新
问题现在似乎已解决,至少对于我们在项目中使用的委托方法而言是这样.
The problem seems fixed now, at least for the delegate methods we are using in our project.
这篇关于Xcode 8 警告“实例方法几乎匹配可选要求"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!