• 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: NSString into *arguments[]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString into *arguments[]


  • Subject: Re: NSString into *arguments[]
  • From: John Stiles <email@hidden>
  • Date: Mon, 01 May 2006 06:51:32 -0700

Kevin Bracey wrote:
thanks for your help,

Is this even possible?

but that gives me an incompatible pointer when I use it later I would like it to be a
char *arguments[]

Well, any function which takes a non-const char* is saying "I could modify this string"... but if it /does/ modify the string, your app may crash (if it modifies the "quoted string") or corrupt memory (if it modifies the [copyToPath UTF8String]).
If you have a function which takes a char* but does not modify the string, change it to take a const char*. This shouldn't cause any problems.
If it /does/ modify the string, then you can't use that function with these strings. It won't work properly.
Honestly I think GCC's standards enforcement is too weak here; const violation should be a bona fide error, not a warning. (If you /must/ violate const, and you're sure it's safe, that's what casting is for.)


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


References: 
 >NSString into *arguments[] (From: Kevin Bracey <email@hidden>)
 >Re: NSString into *arguments[] (From: Nir Soffer <email@hidden>)
 >Re: NSString into *arguments[] (From: Kevin Bracey <email@hidden>)

  • Prev by Date: Re: [CocoaProgrammingForAbsoluteBeginners] Accessing 8-bit bytes from a file using Cocoa
  • Next by Date: Re: How to put a icon in the tray?
  • Previous by thread: Re: NSString into *arguments[]
  • Next by thread: Re: NSString into *arguments[]
  • Index(es):
    • Date
    • Thread