Xcode 8 显示“您想添加存根吗?"我该如何回答? [英] Xcode 8 says "Do you want to add a stub?" How do I answer?
问题描述
在 Xcode 8 中,如果您声明类(或结构)符合协议,但尚未实现所需的方法(函数?),Xcode 将给出此消息Type 'ClassName
' 不符合协议 'ProtocolName
'",这是真的.
如果您通过单击显示三角形打开错误,您将看到许多带有灰色感叹号图标的项目.每个项目都说协议需要功能......你想添加一个存根吗?"我确实想添加一个存根!我如何告诉它为我添加存根?
raphh 的回答是对的,但是 xcode 在这里还是有点问题(至少对我来说),
如果您在编译点标记转换为感叹号后没有立即选择Fix-it
,并且除非您尝试再构建一次,否则您无法使其再次出现.>
在构建之后:点错误图标
当您不立即执行 Fix-it
时:感叹号错误图标
当您有多种方法要实现并且您确实为第一个方法执行了Fix-it
时,您必须重新构建才能再次获得点图标.
In Xcode 8, if you declare that a class (or struct) conforms to a protocol, but haven't implemented the required methods (functions?) Xcode will give this message "Type 'ClassName
' does not conform to protocol 'ProtocolName
'" which is true.
If you open the error by clicking the disclosure triangle, you will see a number of items with grey exclamation mark icons. Each item says "Protocol requires function ... do you want to add a stub?" I do want to add a stub! How do I tell it to add a stub for me?
The answer of raphh is right but xcode is still a little buggy here (at least for me),
If you don't select the Fix-it
right after compiling the dot mark transform to exclamation mark and you can't make it appear again unless you try to build one more time.
Right after building : Dot error icon
When you don't do the Fix-it
right away :
exclamation mark error icon
You have to re-build to get the dot icon again when you have several methods to implement and you did do the Fix-it
for the first one.
这篇关于Xcode 8 显示“您想添加存根吗?"我该如何回答?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!