From 808bde2699ff026f1dc1afa72d9767fd78f7680a Mon Sep 17 00:00:00 2001 From: "C.W. Betts" Date: Sun, 9 Feb 2014 14:46:26 -0700 Subject: [PATCH] Use dot notation in NTSynchronousTask. Change the getter for the done ivar to isDone. --- NTSynchronousTask.m | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/NTSynchronousTask.m b/NTSynchronousTask.m index dbdd3b92..aaba1313 100644 --- a/NTSynchronousTask.m +++ b/NTSynchronousTask.m @@ -18,7 +18,7 @@ @property (retain) NSPipe *outputPipe; @property (retain) NSPipe *inputPipe; @property (readwrite, retain) NSData *output; -@property BOOL done; +@property (getter = isDone) BOOL done; @property (readwrite) int result; @end @@ -32,14 +32,14 @@ - (void)taskOutputAvailable:(NSNotification*)note { - [self setOutput:[[note userInfo] objectForKey:NSFileHandleNotificationDataItem]]; + self.output = [[note userInfo] objectForKey:NSFileHandleNotificationDataItem]; - [self setDone:YES]; + self.done = YES; } - (void)taskDidTerminate:(NSNotification*)note { - [self setResult:[[self task] terminationStatus]]; + self.result = [self.task terminationStatus]; } - (id)init; @@ -47,13 +47,13 @@ self = [super init]; if (self) { - [self setTask:[[[NSTask alloc] init] autorelease]]; - [self setOutputPipe:[[[NSPipe alloc] init] autorelease]]; - [self setInputPipe:[[[NSPipe alloc] init] autorelease]]; + self.task = [[[NSTask alloc] init] autorelease]; + self.outputPipe = [[[NSPipe alloc] init] autorelease]; + self.inputPipe = [[[NSPipe alloc] init] autorelease]; - [[self task] setStandardInput:[self inputPipe]]; - [[self task] setStandardOutput:[self outputPipe]]; - [[self task] setStandardError:[self outputPipe]]; + self.task.standardInput = self.inputPipe; + self.task.standardOutput = self.outputPipe; + self.task.standardError = self.outputPipe; } return self; @@ -79,10 +79,10 @@ BOOL success = NO; if (currentDirectory) - [[self task] setCurrentDirectoryPath: currentDirectory]; + self.task.currentDirectoryPath = currentDirectory; - [[self task] setLaunchPath:toolPath]; - [[self task] setArguments:args]; + self.task.launchPath = toolPath; + self.task.arguments = args; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskOutputAvailable:) @@ -98,7 +98,7 @@ @try { - [[self task] launch]; + [self.task launch]; success = YES; } @catch (NSException *localException) { } @@ -108,12 +108,12 @@ if (input) { // feed the running task our input - [[[self inputPipe] fileHandleForWriting] writeData:input]; - [[[self inputPipe] fileHandleForWriting] closeFile]; + [[self.inputPipe fileHandleForWriting] writeData:input]; + [[self.inputPipe fileHandleForWriting] closeFile]; } // loop until we are done receiving the data - if (![self done]) + if (!self.done) { double resolution = 1; BOOL isRunning; @@ -124,7 +124,7 @@ isRunning = [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:next]; - } while (isRunning && ![self done]); + } while (isRunning && !self.done); } } } @@ -133,7 +133,7 @@ { // we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSData* result=nil; + NSData* result = nil; @try {