Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 29, 2011, 07:55 AM   #1
lynkynpark86
macrumors 6502
 
Join Date: Mar 2010
Location: Maine, USA, Earth, Solar System, Milky Way, Universe
system(someString) causing problems

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?
__________________
White MacBook, 2.13 GHz, 2 GB RAM, 160 GB HD
Dell w/ 4GB RAM, AMD Athlon
iPod Touch 4G (or 5G :P), 32GB, iOS 5.1, awaiting jailbreak.
lynkynpark86 is offline   0 Reply With Quote
Old Jan 29, 2011, 09:31 AM   #2
Guiyon
macrumors 6502a
 
Join Date: Mar 2008
Location: North Shore, 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.
__________________
Make life easier if you have a programming question!
http://www.sscce.org/
Guiyon is offline   0 Reply With Quote
Old Jan 29, 2011, 10:22 AM   #3
lynkynpark86
Thread Starter
macrumors 6502
 
Join Date: Mar 2010
Location: Maine, USA, Earth, Solar System, Milky Way, Universe
I read the man page, and what I gathered is that I should be using sh(), not system(). I tried sh(), and I am now getting an actual error, not a warning. I guess what I'm saying is, how do I run a string as a command on the iPhone?
__________________
White MacBook, 2.13 GHz, 2 GB RAM, 160 GB HD
Dell w/ 4GB RAM, AMD Athlon
iPod Touch 4G (or 5G :P), 32GB, iOS 5.1, awaiting jailbreak.
lynkynpark86 is offline   0 Reply With Quote
Old Jan 29, 2011, 10:29 AM   #4
Guiyon
macrumors 6502a
 
Join Date: Mar 2008
Location: North Shore, 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.
__________________
Make life easier if you have a programming question!
http://www.sscce.org/
Guiyon is offline   0 Reply With Quote
Old Jan 29, 2011, 07:39 PM   #5
lynkynpark86
Thread Starter
macrumors 6502
 
Join Date: Mar 2010
Location: Maine, USA, Earth, Solar System, Milky Way, Universe
Quote:
Originally Posted by Guiyon View Post
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.
__________________
White MacBook, 2.13 GHz, 2 GB RAM, 160 GB HD
Dell w/ 4GB RAM, AMD Athlon
iPod Touch 4G (or 5G :P), 32GB, iOS 5.1, awaiting jailbreak.
lynkynpark86 is offline   0 Reply With Quote
Old Jan 30, 2011, 02:19 PM   #6
bredell
macrumors regular
 
Join Date: Mar 2008
Location: Uppsala, Sweden
Send a message via Skype™ to bredell
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.
bredell is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Tags
erica, problem, system, urlclip, utilities

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Imac Causing a Win 7 system not to sleep?? harleymhs iMac 0 Nov 21, 2013 11:06 AM
Silverlight causing problems thedon1 Mac Applications and Mac App Store 2 Sep 11, 2013 10:51 AM
Plugging in Thunderbolt causing system crash LouisLeLou OS X 10.8 Mountain Lion 4 Sep 9, 2013 11:52 AM
Thunderbolt causing system crash LouisLeLou iMac 0 Sep 6, 2013 06:43 AM
Video causing very high CPU %, slugish system and weird mouse behaviour jamesdrm Mac Pro 5 May 8, 2013 06:37 PM

Forum Jump

All times are GMT -5. The time now is 11:07 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC