NSTask blocking the main thread
I'm using NSTask, but when I launch the task it blocks the main thread (so I can't update it) until the task ends. This is my code: NSString *hostsforping = @"google.es"; pingdata = [[NSTask alloc] init]; [pingdata setLaunchPath: @"/sbin/ping"]; NSArray *pingargs; pingargs = [NSArray arrayWithObjects: @"-c 5", hostsforping, nil]; [pingdata setArguments: pingargs]; NSPipe *pingpipe; pingpipe = [NSPipe pipe]; [pingdata setStandardOutput: pingpipe]; NSFileHandle *pingfile; pingfile = [pingpipe fileHandleForReading]; [pingdata launch]; NSData *pingdata1; pingdata1 = [pingfile readDataToEndOfFile];