NSTask Memory Problems
NSTask Memory Problems
- Subject: NSTask Memory Problems
- From: Owen Anderson <email@hidden>
- Date: Thu, 22 Jan 2004 20:50:23 -0500
Hey,
I was trying to use this snippet I got off the this list a while back,
and I'm having troubles with it. The following snippet works
beautifully the first time, but crashes on the waitUntilExit the second
time round. Any suggestions?
Owen
-(NSArray*)findIt:(NSURL*)theURL
{
NSString* finder = [[[NSBundle mainBundle] pathForResource:@"finder"
ofType:@"py"] stringByStandardizingPath];
NSString* target = [theURL absoluteString];
NSTask* search = [[NSTask alloc] init];
[search setLaunchPath:@"/usr/bin/python"];
NSMutableArray* args = [[NSMutableArray alloc] init];
[args addObject:finder];
[args addObject:target];
[search setArguments:args];
[search setStandardOutput:[NSPipe pipe]];
[search setCurrentDirectoryPath:@"/"];
[search launch];
[search waitUntilExit];
NSData *data;
NSString* tmpString;
data = [[[search standardOutput] fileHandleForReading] availableData];
if ((data != nil) && [data length]) {
tmpString = [[[NSString alloc] initWith
Data:data
encoding:NSUTF8StringEncoding] autorelease];
}
[args release];
[search release];
return [tmpString componentsSeparatedByString:@"\n"];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.