• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Incompatible pointer type
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Incompatible pointer type


  • Subject: Re: Incompatible pointer type
  • From: Julien Jalon <email@hidden>
  • Date: Fri, 15 Jan 2010 15:30:10 +0000

1) never do "NSLog(completeString)" but "NSLog(@"%@", completeString);
2) system() uses a C string, not an NSString. What you want is "system([completeString cStringUsingEncoding:NSUTF8StringEncoding])"

On Fri, Jan 15, 2010 at 3:23 PM, Gary McGill <email@hidden> wrote:

I am trying to pass a variable to system(). The final code would look like this:
system(“lp –d Internal_Modem –o phone=555-5555 ~/Desktop/fileToFax.pdf”)

If I simply put this line in my code, it works fine. The problem is I have to get the phone number from the database. When I build the string using AppendString I get “warning: passing argument 1 of ‘system’ from incompatible pointer type. Here is the code that builds the string:

      
NSString *numberToCall = [faxNumber stringValue];  // this gets the fax number from the database
    NSString *fileToPrint = @" ~/Desktop/fax.pdf";
    NSString *firstPartOfString = @"lp -d Internal_Modem -o phone=";
    NSString *addFaxNumber = [firstPartOfString stringByAppendingString:numberToCall];
    NSString *completeString = [addFaxNumber stringByAppendingString:fileToPrint];
    system(completeString); // THIS SHOULD WORK BUT DOES NOT
   NSLog(completeString);

In the run log the NSLog(completeString) looks perfect.
It also says “sh: line 1:  \240{\266x: command not found”

Why am I getting an incompatible pointer type?

Really all I need to do is pass the fax number variable to the system() call. If there is an easier way to do this I would greatly appreciate your comments.

Thanks,

Gary

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Incompatible pointer type
      • From: Gary McGill <email@hidden>
    • Re: Incompatible pointer type
      • From: Julien Jalon <email@hidden>
References: 
 >Incompatible pointer type (From: Gary McGill <email@hidden>)

  • Prev by Date: Re: Incompatible pointer type
  • Next by Date: Re: Incompatible pointer type
  • Previous by thread: Re: Incompatible pointer type
  • Next by thread: Re: Incompatible pointer type
  • Index(es):
    • Date
    • Thread