Skip to content

cheizer/GCDTask

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GCDTask is a wrapper for NSTask that allows for handling input, output and error streams just by providing a block to handle it.

GCDTask — NSTask with blocks and GCD.

GCDTask is a wrapper for NSTask that tries to use GCD as much as possible and provide a simple block-based interface for use.

Example usage:

    GCDTask* pingTask = [[GCDTask alloc] init];
    
    [pingTask setArguments:@[@"-c",@"4",@"8.8.8.8"]];
    [pingTask setLaunchPath:@"/sbin/ping"];
    
    [pingTask launchWithOutputBlock:^(NSData *stdOutData) {
        NSString* output = [[NSString alloc] initWithData:stdOutData encoding:NSUTF8StringEncoding];
        NSLog(@"OUT: %@", output);
    } andErrorBlock:^(NSData *stdErrData) {
        NSString* output = [[NSString alloc] initWithData:stdErrData encoding:NSUTF8StringEncoding];
        NSLog(@"ERR: %@", output);
    } onLaunch:^{
        NSLog(@"Task has started running.");
    } onExit:^(int exitStatus) {
        NSLog(@"Task has now quit. Exit status %d",exitStatus);
    }];

License

View the LICENSE file for more info.

About

NSTask + Blocks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 80.9%
  • Ruby 19.1%