Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error in NSTask launch



development2 wrote:

I know it is something I am doinig but I am getting an error I can't seem to figure out. Here the code and then the error.

NSString *exePath = [[NSBundle bundleWithIdentifier:@"com.yourcompany.SetupDevice"] pathForResource:@"upnpsearch" ofType:@""];

RunCommand *command = [[RunCommand alloc] initWithPath:exePath];
// set up the args
NSNumber *time = [NSNumber numberWithInt:15];
NSString *destPath = [NSString stringWithString:@"/tmp"];
NSArray *myArray = [NSArray arrayWithObjects: time, destPath, nil];
[command setArgs:myArray];
int result = [command execute];


Now in execute tI have the call:

[task launch];

I get the error:
2008-10-16 19:36:21.530 Installer[39330:813] *** -[NSCFNumber fileSystemRepresentation]: unrecognized selector sent to instance 0x3fbe9a20
(gdb) continue
2008-10-16 19:36:24.751 Installer[39330:813] *** -[NSCFNumber fileSystemRepresentation]: unrecognized selector sent to instance 0x3fbe9a20


Now I know this is on the arguments that I am passing in to the command line, but they look fine to em (Above in code) can anyone else see anything wrong?

Thanks,


well you're exec'ing a shell command, which needs command-line arguments as strings. So each of your arguments is being converted to a string ready to be sent to the shell. That's accomplished by calling fileSystemRepresentation on each of them. As you can see, NSCFNumber (ie your NSNumber) doesn't implement that method, which isn't that surprising, there is no one fileSystemRepresentation of a number, you might want an integer, or a float with a given number of decimals or the word TRUE or .. anything.


You need to figure out what your shell command actually wants in string format, convert your NSNumber explicitly to that, and then pass that as an NSString
_______________________________________________


Cocoa-dev mailing list (email@hidden)

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/email@hidden

This email sent to email@hidden
References: 
 >Error in NSTask launch (From: development2 <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.