Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

lynkynpark86

macrumors 6502
Original poster
I'm trying to get better at Obj-C, and I'm making a series of simple apps. For developers of cydia apps, I'm sure you've heard of the Erica Utilities. I'm using the urlclip utility to make an app that makes a webclip. Here's my code:
Code:
-(IBAction)makeClip {
	
	urlString = [[NSString alloc] initWithFormat:urlField.text];
	nameString = [[NSString alloc] initWithFormat:nameField.text];
	cmdString = [[NSString alloc] initWithFormat:@"urlclip %@ %@", nameString, urlString];
	system(cmdString);
	
}
But my system(cmdString) line is getting a warning: "Passing argument 1 of 'system' from incompatible pointer type". Is it because I'm using a string within system()? I tested it on my device, and it isn't working. The cmdString string is working right, as I tested it with a UIAlertView. The problem IS in the system(). Any ideas?
 

Guiyon

macrumors 6502a
Mar 19, 2008
771
4
Cambridge, MA
The warning is GCC telling you are trying to call the system function in a way that does not match it's definition (and it is completely correct). system(3) is a function from the Standard C library and expects C (not Objective-C) datatypes. I would suggest opening up a Terminal window and typing:
Code:
man system

and read the function's man page to get some idea about how it's declared, the number of type of it's arguments, etc.
 

Guiyon

macrumors 6502a
Mar 19, 2008
771
4
Cambridge, MA
Re-read the man page (specifically the 'Synopsis' section), the function you are using is correct but you are not calling it with the correct arguments. If you are still stuck after that, here's another hint: Take a look at the NSString class reference, one of it's methods will convert the string into the form you need.
 

lynkynpark86

macrumors 6502
Original poster
Re-read the man page (specifically the 'Synopsis' section), the function you are using is correct but you are not calling it with the correct arguments. If you are still stuck after that, here's another hint: Take a look at the NSString class reference, one of it's methods will convert the string into the form you need.

Are you talking about const char? I'm assuming it's not int you're talking about. So I need NSStringEncoding? How would I type that? I'm sorry I'm asking you so spell it out for me, but I am very new to programing.
 

bredell

macrumors regular
Mar 30, 2008
127
1
Uppsala, Sweden
I'm pretty sure you're not allowed to use the system(3) call on an iOS device. system(3) uses the fork(2) call, and that call is blocked by Apple.

But don't take my word for it, last time I tried using it was almost a year ago and things might have changed since then.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.