Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Fix weird bug when trying to set the port in the bind function from ChromeSocketUdp.m #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/ios/ChromeSocketsUdp.m
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,15 @@ - (void)bind:(CDVInvokedUrlCommand*)command
{
NSNumber* socketId = [command argumentAtIndex:0];
NSString* address = [command argumentAtIndex:1];
NSUInteger port = [[command argumentAtIndex:2] unsignedIntegerValue];
NSNumber* portPointer = [command argumentAtIndex:2];
NSUInteger port;
@try {
port = [portPointer unsignedIntegerValue];
} @catch (NSException *exception) {
port = 0; //HOTFIX fix bug in cordova 6.0.2
// the error thrown is : [NSTaggedPointerString unsignedIntegerValue]: unrecognized selector sent to instance
// set the value to 0 if it fails so that the port would be at least set automatically instead of just crashing silently.
}

if ([address isEqualToString:@"0.0.0.0"])
address = nil;
Expand Down