gpt4 book ai didi

objective-c - Swift Does not conform to protocol 报错采用Objective C Protocol

转载 作者:搜寻专家 更新时间:2023-10-31 22:48:05 24 4
gpt4 key购买 nike

<分区>

尝试在我的 swift 代码中采用 objective-c 协议(protocol)时,我不断收到“类型不符合协议(protocol)”错误。我正在实现所有必需的方法,但编译器为每个方法都给出了错误。

Objective-C文件中的协议(protocol)声明是

@protocol RBLProtocolDelegate
-(void) protocolDidReceiveCustomData:(uint8_t *) data length:(uint8_t) length;
-(void) protocolDidReceiveProtocolVersion:(UInt8) major Minor:(UInt8) minor Bugfix:(UInt8) bugfix;
-(void) protocolDidReceiveTotalPinCount:(uint8_t) count;
-(void) protocolDidReceivePinCapability:(uint8_t) pin Value:(uint8_t) value;
-(void) protocolDidReceivePinMode:(uint8_t) pin Mode:(uint8_t) mode; /* mode: I/O/Analog/PWM/Servo */

-(void) protocolDidReceivePinData:(uint8_t) pin Mode:(uint8_t) mode Value:(uint8_t) value;
@end

在我的 swift 文件中我有(这只是其中一种方法,我也实现了所有其他方法,但为了简洁起见我只展示一个)

 @objc func protocolDidReceiveProtocolVersion(major: UInt8, minor: UInt8, bugfix: UInt8) {

}

产生编译器错误:

Objective-C method 'protocolDidReceiveProtocolVersion:minor:bugfix:' provided by method 'protocolDidReceiveProtocolVersion(_:minor:bugfix:)' does not match the requirement's selector ('protocolDidReceiveProtocolVersion:Minor:Bugfix:')

Screenshot of issue in xcode

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com