Log on main thread

This commit is contained in:
Matthias Neeracher 2017-11-24 06:01:22 +01:00
parent 423250f8cd
commit 8cdf61cf07

View File

@ -45,10 +45,11 @@
[log setString: logText]; [log setString: logText];
while ((data = [h availableData]) && [data length]) { while ((data = [h availableData]) && [data length]) {
NSString * append = [[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding] autorelease]; NSString * append = [[[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding] autorelease];
[logText appendString: append]; dispatch_sync(dispatch_get_main_queue(), ^{
[log setString: logText]; [logText appendString: append];
[log scrollRangeToVisible: NSMakeRange([logText length], 0)]; [log setString: logText];
[log scrollRangeToVisible: NSMakeRange([logText length], 0)];
});
[pool release]; [pool release];
pool = [[NSAutoreleasePool alloc] init]; pool = [[NSAutoreleasePool alloc] init];
} }