0

I'm developing an iOS application in swift, which socket.io library classes written in objective C.

When I updated the Xcode to 6.3.2, I'm getting lot of errors

@protocol SocketIODelegate <NSObject>
@optional
- (void) socketIO:(SocketIO *)socket didReceiveMessage:(SocketIOPacket *)packet;
- (void) socketIO:(SocketIO *)socket didReceiveJSON:(SocketIOPacket *)packet;
- (void) socketIO:(SocketIO *)socket didReceiveEvent:(SocketIOPacket *)packet;
- (void) socketIO:(SocketIO *)socket didSendMessage:(SocketIOPacket *)packet;
- (void) socketIO:(SocketIO *)socket onError:(NSError *)error;
- (void) socketIO:(SocketIO *)socket onFailWithError:(NSError *)error;
@end

When I implementing these delegate methods in swift class i'm getting "definition conflicts with previous value"

The implemented delegate methods in swift are like:

func socketIO(socket: SocketIO!, onFailWithError error: NSError!) {}

func socketIO(socket: SocketIO!, onError error: NSError!){}

func socketIO(socket: SocketIO!, didReceiveEvent packet: SocketIOPacket!) {}

How to solve this issue?

Dev
  • 3,885
  • 10
  • 39
  • 65

1 Answers1

1

Using Xcode 6.3.2 and implementing the delegate methods worked just fine for me.

I could only reproduce the error message you mentioned after reading this SO question here: Unable to overload function in viewDidLoad() in swift

This indeed fails to compile for me with definition conflicts with previous value:

func whatever() {
    func socketIO(socket: SocketIO!, onFailWithError error: NSError!) {}

    func socketIO(socket: SocketIO!, onError error: NSError!){}

    func socketIO(socket: SocketIO!, didReceiveEvent packet: SocketIOPacket!) {}
}

So try to move the implementation of the delegate methods out of another function, hopefully that's the issue on your side too.

Community
  • 1
  • 1
Peter Tutervai
  • 793
  • 12
  • 21