的使用我采取一个类,但我得到这个错误:斯威夫特:未声明的类型
Use of undeclared type 'myProtocol'
这里是我的代码:
class LocalContactService: myProtocol{
任何的你知道为什么我得到这个错误?
的使用我采取一个类,但我得到这个错误:斯威夫特:未声明的类型
Use of undeclared type 'myProtocol'
这里是我的代码:
class LocalContactService: myProtocol{
任何的你知道为什么我得到这个错误?
转到您的myProtocol
类,并在右侧(如果您使用的是XCode),请单击您的班级的测试。这就是我的意思。
"Use of undeclared type" in Swift, even though type is internal, and exists in same module
也许你从来没有定义myProtocol
。或者如果你有,也许它在LocalContactService
类中的范围内
如何定义协议? – user2924482
下面是一些例子:https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Protocols.html一个基本的定义(没有任何有用的内容)就是'protocol myProtocol {}' –
这个正是我的问题!我把它放在同一个文件中,所以不是很明显。谢谢 – rr1g0
您是否声明了协议“myProtocol”?如果是这样,请告诉我们声明。如果没有,我建议您阅读https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Protocols.html –