协议只能用作通用

时间:2015-09-22 17:56:33

标签: ios iphone swift

我正在尝试在我的班级使用协议,这里是代码

rm(g1, g2, g3, g4, g5)

然后我有其他类,我创建使用我的协议的类

public protocol Channel {

 typealias CallBackType
 func onResponse(responseDic: NSDictionary)
 func onRequest(responseDic: NSDictionary)
 func onBroadcast(responseDic: NSDictionary)
 func request(var messageDic: [String:String]) -> Promise<Any>
 func broadcast(var messageDic:[String:AnyObject])
 func listen(messageDic:[String: AnyObject], callback:CallBackType)
}

这是SystemChannel类

public  class SocketManager {
  var systemChannel:SystemChannel?
public var socket = SocketIOClient(socketURL: hostUrl, options: ["log":      false,
    "reconnects": true,
    "reconnectAttempts": 5,
    "reconnectWait": 5,
    "connectParams": ["token":tokenSDK]])

public func start_socket() -> Promise<Bool> {
 systemChannel = SystemChannel(socket: self.socket)
}

public func getChannel(typeChannel:SOCKET_CHANNELS) -> Channel{
    switch typeChannel{
        case .SYSTEM:
            return  systemChannel!
        default:
            return systemChannel!
    }
}
}

但是我在getChannel方法public class SystemChannel: Channel { public typealias CallBackType = [String: AnyObject] -> Void }

上遇到编译错误

0 个答案:

没有答案