• 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: Escaping white space in an NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Escaping white space in an NSString


  • Subject: Re: Escaping white space in an NSString
  • From: Seth Willits <email@hidden>
  • Date: Wed, 20 May 2009 22:30:54 -0700

On May 20, 2009, at 10:23 PM, Bruce Johnson wrote:

I have a unix path in an NSString via [[NSBundle bundleForClass: [self
class]] pathForResource:  etc.. etc..
The problem is that the path has white spaces scattered in the string.
And I need to pass the unix path to a CLI application.  The CLI app
croaks on the white spaces (for obvious reasons)

Is there a standard Cocoa way of escaping the white spaces like is
done in the Terminal Application (I'm not looking for percent escapes)
that has eluded my searches today?

I also would like it to work in both Leopard and iPhone.


Well, if you're firing off the command line app from within your Cocoa app, typically you'd be using NSTask and simply pass the string as an argument without having to escape it. There's no built-in way to escape strings for a shell because Cocoa doesn't interact with any shell instances and what has to be escaped depends on the destination.



--
Seth Willits



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Escaping white space in an NSString (From: Bruce Johnson <email@hidden>)

  • Prev by Date: Re: Menu item with 'title' bound is always enabled. Bug?
  • Next by Date: Binding 'Enabled' to NSObjectController.selection NSIsNotNil fails?
  • Previous by thread: Escaping white space in an NSString
  • Next by thread: Re: Escaping white space in an NSString
  • Index(es):
    • Date
    • Thread