pkyeck/socket.IO-objc

Init is not properly defined.

Opened this issue · 0 comments

When using init without setting the id delegate on initialization
The result is:

_queue = nil
_acks = nil

Which cause problems with acknowledgements.
Which implies that inorder to use the library you must initialize with a delegate.
That is incorrect.

Following changes allow init to be used if not used with a delegate and allow the library to function.

- (id) init
{
    self = [super init];
    if (self) {
        _delegate = nil;
        _queue = [[NSMutableArray alloc] init];
        _ackCount = 0;
        _acks = [[NSMutableDictionary alloc] init];
        _returnAllDataFromAck = NO;
    }

    return self;
}

- (id) initWithDelegate:(id<SocketIODelegate>)delegate
{
    self = [super init];
    if (self) {
        _delegate = delegate;
    }
    return self;
}

the pull request is available.