Swift各种初见的报错信息

1、实现UITableViewDataSource ,报错如下:

Type 'ViewController' does not conform to protocol 'UITableViewDataSource'

解决方案:
实现UITableViewDataSource中得Required方法numberOfRowsInSectioncellForRowAtindexPath

需要实现的方法

2、import创建的类

No Such module 'TestCell'

解决方案:Swift不同于OC,不需要import,直接使用类即可。

3、使用Alamofire 等类库的报错信息

Library not loaded: @rpath/Alamofire.framework/Alamofire
Referenced from: /Users/RenChao/Library/Developer/CoreSimulator/Devices/6FE81DB6-45BC-49EF-AE2D-5B0D9D561CFE/data/Containers/Bundle/Application/6ED53429-45B4-496D-978F-BCB64F567159/YiNiuGuSwift.app/YiNiuGuSwift
Reason: image not found

解决方案:General -> Embedded Binaries -> + -> Add Other,添加Alamofire.framework

4、使用泛型协议,编译提示

Ambiguous reference to member 'XXXX'

解决方案:
指定泛型的具体类型。

5、@IBOutlet修饰的属性没有相应地连线

This Class is not Key Value Coding-Compliant for the Key 'XXXX'

解决方案:
全局搜索XXXX,连线即可

6、StoryBoard使用第三方类库的View、ViewController报错

Unknown class XXX in Interface Builder file

解决方案:
添加XXX所在的模块名称,如下图所示。


StoryBoard使用第三方类库
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容