Fixed threading in ios

This commit is contained in:
aaa 2014-10-10 17:04:49 +01:00
parent 9429adb034
commit 479c5003bd
2 changed files with 9 additions and 1 deletions

View File

@ -20,11 +20,18 @@ NSOutputStream *outputStream;
inputStream = (__bridge NSInputStream *)readStream; inputStream = (__bridge NSInputStream *)readStream;
[inputStream setDelegate:self]; [inputStream setDelegate:self];
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; //[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[inputStream open]; [inputStream open];
outputStream = (__bridge NSOutputStream *)writeStream; outputStream = (__bridge NSOutputStream *)writeStream;
[outputStream open]; [outputStream open];
[self performSelectorOnMainThread:@selector(runReadLoop) withObject:nil waitUntilDone:NO];
}
- (void)runReadLoop {
[inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
} }
- (void)close { - (void)close {

View File

@ -69,6 +69,7 @@
[self.commandDelegate runInBackground:^{ [self.commandDelegate runInBackground:^{
@try { @try {
[socket connect:host port:port]; [socket connect:host port:port];
[self.commandDelegate [self.commandDelegate
sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]
callbackId:command.callbackId]; callbackId:command.callbackId];