仍然尝试习惯,但由于我的obj-c知识接近0,所以我无法实现这个SocketRocket协议.任何帮助将不胜感激
这是我试图实现的对象代理
@protocol SRWebSocketDelegate <NSObject> // message will either be an NSString if the server is using text // or NSData if the server is using binary. - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message; @optional - (void)webSocketDidOpen:(SRWebSocket *)webSocket; - (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error; - (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean; @end
我希望这是实施它的正确方法;不是…
我得到’SocketDelegate’不符合协议’SRWebSocketDelegate’
class SocketDelegate:UIViewController,SRWebSocketDelegate{ let socket:SRWebSocket! = SRWebSocket() override func loadView() { self.socket.delegate = self } func didReceiveMessage(message:AnyObject){ } }