NSTask
NSTask
- Subject: NSTask
- From: "Sprague, Graham" <email@hidden>
- Date: Wed, 27 Jun 2001 17:33:33 -0400
I am using NSTask to wrap the Locate Command. I was wondering is someone
could help me with the output. I would like to take the found items in
Standard output and put them into a NSScrollView Control. Is this possible?
Keep in mind that I am quite a newbie when it comes to Cocoa. Your patience
is appreciated in advance. See my comments in the code below.
P.S. I am still waiting for my Learing Cocoa book from Amazon.com.
@implementation locateWrapper
- (IBAction)displayFilePath:(id)sender
{
}
- (IBAction)locate:(id)sender
{
[goButton setTitle:@"Searching"];
[goButton setEnabled:NO];
locate=[[NSTask alloc] init];
[locate setLaunchPath:@"/usr/bin/locate"];
[locate setArguments:[NSArray arrayWithObject:[criteria stringValue]]];
/* below is where I thought I might set the destination for Standard output.
am I on the right track? */
[locate setStandardOutput:[***************]]
[locate launch];
}
-(id)init {
self = [super init];
/* Also I thought I might need to do something here with the notification
center to get results as the come into stdo? */
[[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
Graham Sprague
STAPLES, INC.
508-253-8170
email@hidden