Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 29, 2011, 06: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, 08: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, 09: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, 09: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, 06: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, 01: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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
AT&T's Server Problems Continue to Cause Problems for iPhone 4 Pre-Orders MacRumors MacRumors.com News Discussion 785 Sep 21, 2012 03:07 PM
Brightness/sound/keyboard-backlight controls causing problems on a 15" G4 Powerbook. brade Macintosh Computers 2 Apr 8, 2004 09:47 AM
Adding Fonts causes problems in Safari foniks2020 Mac OS X 10.3 (Panther) Discussion 1 Oct 27, 2003 08:36 AM
iPod causing problems with other FW devices? crazytom Macintosh Computers 0 Aug 27, 2003 03:27 PM


All times are GMT -5. The time now is 05:11 AM.

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

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