我在斯威夫特文件中聲明:斯威夫特協議錯誤
protocol SocketManagerDelegate {
func webSocketDidReceiveMessage(message:Message)
func socketWasReconnected()
func webSocketDidFailWithError(error:String)
}
import Foundation
import MDWamp
import SSKeychain
@objc(SocketManager)
class SocketManager: NSObject, MDWampClientDelegate{
static let instance = SocketManager()
var delegate:SocketManagerDelegate?
,我想使用的協議在ObjC文件:
#import <Project-Swift.h>
@interface ChatManager() <SocketManagerDelegate>
@end
@implementation ChatManager.........
我得到這個錯誤:
無法弄清楚這一點。想法?
在我project-swift.h
文件中的變異delegate
是完全無法顯示:
SWIFT_CLASS_NAMED("SocketManager")
@interface SocketManager : NSObject <MDWampClientDelegate>
SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, strong)
SocketManager * _Nonnull instance;)
+ (SocketManager * _Nonnull)instance SWIFT_WARN_UNUSED_RESULT;
@property (nonatomic, strong) MDWamp * _Null_unspecified wampConnection;
@property (nonatomic, readonly, copy) NSString * _Nonnull socketUrlSecure;
@property (nonatomic, readonly, copy) NSString * _Nonnull socketUrl;
嘗試@objc協議SocketManagerDelegate替換代碼:類{} –
@MikeAlter您的解決方案並獲得成功。謝謝。添加一個答案,我會接受它。 – Gal
歡迎,添加下面的答案 –