Type '' cannot conform to protocol '' because it has requirements that cannot be satisfied
我有一个Objective-C协议,我试图在Swift类中实现。例如:
@class AnObjcClass;
@protocol ObjcProtocol <NSObject>
- (void)somethingWithAnArgument:(AnObjcClass *)arg;
@end
当我尝试在这样的Swift类中符合它时:
@objc class SwiftClass: NSObject, ObjcProtocol {
// ...
}
我得到以下可怕的编译器错误:
Type '' cannot conform to protocol '' because it has requirements that cannot be satisfied
我该如何解决这个问题?
解决方案:
确保该协议引用的任何类都包含在桥接头中。
当协议中使用的某个类型(协议本身,返回类型,参数类型)未包含在Swift桥接头中时,会发生此错误。
由于@class AnObjcClass前向声明,Objective-C类可以愉快地实现此协议,但似乎Swift类不能实现使用仅向前声明的类的协议。
Type '' cannot conform to protocol '' because it has requirements that cannot be satisfied的更多相关文章
- type 'simple Class' does not conform to protocol 'Example Protocol'错误
在看swift教程中"接口和扩展"这小部分. 在编写时提示"type 'simple Class' does not conform to protocol 'Examp ...
- 'String' does not conform to protocol 'CollectionType' Error in Swift 2.0
如下是报错需要修改的源码: // if count(currentPassword) < 6 || count(newPassword) < 6 || count(confirmPassw ...
- cannot conform to protocol 的一点事
学习UITableView过程中,回想视频打一遍代码,发现卡在了第一步.一直显示无法继承协议,而且还多了一个错误:definition conflicts with previous value.百度 ...
- Swift 给UITableView 写extension 时 报错 does not conform to protocol 'UITableViewDataSource'
那是因为你没有实现 数据源和代理方法 实现下就好了 func tableView(_ tableView: UITableView, numberOfRowsInSection section: In ...
- Breaking Down Type Erasure in Swift
Type Erasure Pattern We can use the type erasure pattern to combine both generic type parameters and ...
- swift和oc的protocol的成员变量
都需要协议实现者提供具体变量: 否则认为不符合协议. @protocol edddd <NSObject> @property(nonatomic, strong) NSObject *e ...
- The WebSocket Protocol
[Docs] [txt|pdf] [draft-ietf-hybi-t...] [Diff1] [Diff2] [Errata] Updated by: 7936 PROPOSED STANDAR ...
- 转iOS中delegate、protocol的关系
iOS中delegate.protocol的关系 分类: iOS Development2014-02-12 10:47 277人阅读 评论(0) 收藏 举报 delegateiosprocotolc ...
- protocol(协议) 和 delegate(委托)也叫(代理)---辨析
protocol和delegate完全不是一回事. 协议(protocol),(名词)要求.就是使用了这个协议后就要按照这个协议来办事,协议要求实现的方法就一定要实现. 委托(delegate),(动 ...
随机推荐
- tensorflow、cuda、cudnn之间的版本对应关系
原文链接 tensorflow-gpu v1.9.0 | cuda9.0 | cuDNN7.1.4可行 | 备注:7.0.4/ 7.0.5/ 7.1.2不明确 tensorflow-gpu v1. ...
- tensorflow 1.0 学习:用别人训练好的模型来进行图像分类
谷歌在大型图像数据库ImageNet上训练好了一个Inception-v3模型,这个模型我们可以直接用来进来图像分类. 下载地址:https://storage.googleapis.com/down ...
- Linq使用Group By
1.简单形式: var q = from p in db.Products group p by p.CategoryID into g select g; 语句描述:Linq使用Group By按C ...
- asp.net core系列 35 EF保存数据(2) -- EF系列结束
一.事务 (1) 事务接着上篇继续讲完.如果使用了多种数据访问技术,来访问关系型数据库,则可能希望在这些不同技术所执行的操作之间共享事务.下面示例显示了如何在同一事务中执行 ADO.NET SqlCl ...
- 从零打卡leetcode之day 4--无重复最长字符串
题目描述: 给定一个字符串,找出不含有重复字符的最长子串的长度. 示例: 给定 "abcabcbb" ,没有重复字符的最长子串是 "abc" ,那么长度就是3. ...
- scrapy pipelines导出各种格式
scrapy在使用pipelines的时候,我们经常导出csv,json.jsonlines等等格式.每次都需要写一个类去导出,很麻烦. 这里我整理一个pipeline文件,支持多种格式的. # -* ...
- JDK源码分析(8)之 Reference 完全解读
在阅读本文之前最好对 Reference 框架有一个整体的把握,可以参考我上一篇博客 Reference 框架概览 :本文主要讲了 Reference 的子类实现和应用(SoftReference,W ...
- 【Java并发编程】Callable、Future和FutureTask的实现
启动线程执行任务,如果需要在任务执行完毕之后得到任务执行结果,可以使用从Java 1.5开始提供的Callable和Future 下面就分析一下Callable.Future以及FutureTask的 ...
- Pycharm远程调试原理及配置
工作中使用Pycharm作为python开发的IDE,作为专业的python集成开发环境,其功能之强大令人折服.开发过程中Debug是必不可少的.平时经常使用Pycharm的remote debug功 ...
- 适用于app.config与web.config的ConfigUtil读写工具类
之前文章:<两种读写配置文件的方案(app.config与web.config通用)>,现在重新整理一个更完善的版本,增加批量读写以及指定配置文件路径,代码如下: using System ...