Swift中出现 use of undeclared type ***Delegate错误的解决方法
来源:互联网 发布:中软国际java面试题 编辑:程序博客网 时间:2024/06/05 19:44
出现这种错误可能因为类名跟函数名冲突,特别是在出现代理的时候,
这个错误,你会发现真的很难找,只要不是会用代理就没问题,一调用代理就提示你找不到use of undeclared type ***Delegate
这问题。为什么说头疼,Swift调用OC的,oc的代码都是好好都是按照格式来的,没问题。Swift中你写的也对,绝对没问题。哎。。。
例如
#import <UIKit/UIKit.h>@class CustomSearchBar;@protocol CustomsearchResultsUpdater <NSObject>@required/**第一步根据输入的字符检索 必须实现*/-(void)CustomSearch:(CustomSearchBar *)searchBar inputText:(NSString *)inputText;@end@interface CustomSearchBar : UIView@property (nonatomic, weak) id<CustomsearchResultsUpdater> searchResultsUpdater;@end
用Swift遵守上面OC写的协议时肯定在在swift处报use of undeclared type *错。因为Delegate里面的方法CustomSearchBar
跟类名CustomSearchBar
冲突了。以下这句话引自stackoverflow的回答:(http://stackoverflow.com/questions/24627598/use-of-undeclared-type-in-swift-project)
Your delegate function name is VKConnector and you also have a class named VKConnector. That's your conflict. In Objective C your delegate method is VKConnector:withBool: but in Swift it's simply VKConnector and withBool is not a part of the name.
如有问题可添加我的QQ:1290925041
还可添加QQ群:234812704(洲洲哥学院)
欢迎各位一块学习,提高逼格!
也可以添加洲洲哥的微信公众号
更多消息
更多信iOS开发信息 请以关注洲洲哥 的微信公众号,不定期有干货推送:
- Swift中出现 use of undeclared type ***Delegate错误的解决方法
- 关于swift中出现 use of undeclared type ***错误的一种解决方法
- 关于‘Use of undeclared type’的错误!
- Xcode的Swift项目中已经导入XMPPFramework编译仍出错:Use of undeclared type ‘XMPPStream’
- stm32 keil中出现use of undeclared identifier' '的原因
- Xcode6出现SDWebImage框架Use of undeclared identifier '_excuting' 的错误
- Xcode 出现Use of undeclared identifier 'GL_BGRA_EXT'的解决
- xcode出现 use of undeclared identifier
- 编译openssl库时出现“error C2027: use of undefined type 'in6_addr'”的解决方法
- illegal use of this type as an expression错误出现的原因
- swift 委托模式delegate 中出现的莫名其妙的错误EXC_BAD_ACCESS
- 解决IOS开发使用Lumberjack库时出现的Use of undeclared identifier 'ddLogLevel'问题
- 导入AFN框架出现问题Use of undeclared identifier ‘kSecFormatUnknown’
- php当中出现的错误:Use of undefined constant title - assumed 'title'的解决方法
- Use of undeclared identifier 'BMKMapPointMake'错误 (百度地图)
- Use of undeclared identifier 'CHAT_SENDMESSAGE_STATUS'
- iOS - use of undeclared identifier
- Use of undeclared identifier 'OBJC_ASSOCIATION_RETAIN_NONATOMIC'
- 关于泰勒展开
- Sublime text3 连接sftp/ftp(远程服务器)
- 蓝鸥iOS从零基础到精通就业-C语言入门 11函数一
- 《Effective Objective-C 2.0》读书笔记---第三章
- React Native中的网络请求fetch和简单封装
- Swift中出现 use of undeclared type ***Delegate错误的解决方法
- 理解LSTM网络
- Android热修复实践应用—AndFix
- shell 教程四:基本运算符(算数,关系,布尔,字符串,文件检测)
- 每天一个 Linux 命令(4):mkdir
- 蓝鸥iOS从零基础到精通就业-C语言入门 12函数二
- BPM SharePoint解决方案分享
- npm 安装git项目的几种方式
- 自定义圆形头像