On 1 Oct 2008, at 18:25, Shawn Protsman wrote:
I finally decided to take a dive into Objective-C with Xcode. I'm looking at the iPing example in Hillegass' latest book, Cocoa Programming. iPing works fine as coded in the book. Next, I decided to replace `ping` with a binary I wrote called `keyreq`. It is simply a C program and resides in /usr/local/bin.
[snip]
Here is the project code for the startStopPing method (the relevant part that I think I should change) of iPing:task = [[NSTask alloc] init]; [task setLaunchPath:@"/sbin/ping"]; NSArray *args = [NSArray arrayWithObjects:@"-c10", [hostField stringValue], nil]; [task setArguments:args];Perhaps stupidly, I thought I could just swap out setLaunchPath and then change NSArray:task = [[NSTask alloc] init]; [task setLaunchPath:@"/usr/local/bin/keyreq"]; NSArray *args = [NSArray arrayWithObject:[hostField stringValue]]; [task setArguments:args];'Build and Go' compiles clean but upon entering a number, like 1 in hostField, and then clicking 'Start' results in the 'Debugger Console' going to gdb. With the above modification, I can return setLaunchPath to /sbin/ping and the program works fine.
As a novice myself I can't immediately spot a problem with what you have done so it may be that the error is not in the code you have pasted into your message. If you add a breakpoint and step through you should be able to find out exactly where the code is failing which would make it easier to track down the problem.
I'd suggest adding a breakpoint to the line where you initialise the NSTask object and then step through your code until it errors and then post back here with more details.
Simon _______________________________________________ Cocoa-dev mailing list ([email protected]) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
