• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: NSTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: NSTask


  • Subject: RE: NSTask
  • From: "Sprague, Graham" <email@hidden>
  • Date: Thu, 28 Jun 2001 08:50:30 -0400

Ok,

I got the results to go into a text field(resultList). How do I clear the
text field before the next search? I tried setting it to nil but that won't
work. I think I must be missing something very simple. Could anyone help?

Here's is my code...


#import "locateWrapper.h"

@implementation locateWrapper

- (IBAction)displayFilePath:(id)sender
{
}

- (IBAction)locate:(id)sender
{
NSPipe *thePipe=[NSPipe pipe];
NSFileHandle *pipeOutput=[thePipe fileHandleForReading];
NSData *outData=nil;
NSString *theString=nil;

[goButton setTitle:@"Searching"];
[goButton setEnabled:NO];

locate=[[NSTask alloc] init];
[locate setLaunchPath:@"/usr/bin/locate"];


// I thought this might work but no dice.
//[resultList setStringValue:nil];

[locate setArguments:[NSArray arrayWithObject:[criteria stringValue]]];
[locate setStandardOutput:thePipe];
[locate launch];



// Wait until the task finishes
//[locate waitUntilExit];


while ((outData=[pipeOutput availableData]) && ([outData length]))
{
theString=[[NSString alloc] initWithData:outData
encoding:NSASCIIStringEncoding];
[resultList setStringValue:[[resultList stringValue]
stringByAppendingString:theString]];
[theString release];
}


}
-(id)init {
self = [super init];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(finishedLocate:)name:NSTaskDidTerminateNotification
object:nil];
locate = nil;
return self;
}

-(void)finishedLocate:(NSNotification *)aNotification {
[goButton setTitle:@"Go"];
[goButton setEnabled:YES];
[locate release];
locate=nil;
}

-(BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication
*)theApplication {
return YES;
}



- (IBAction)showInFinder:(id)sender
{
}

@end


  • Prev by Date: Drag&Drop between Carbon and Cocoa ?
  • Next by Date: Re: Opening Terminal App at path?
  • Previous by thread: NSTask
  • Next by thread: RE: NSTask
  • Index(es):
    • Date
    • Thread