definition conflicts with previous value - Xcode 6.3.2

1.5k views Asked by At

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?

1

There are 1 answers

0
Peter Tutervai On

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.