• 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: Re: Correct usage of replaceOccurencesOfString:withString:options:range
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: Correct usage of replaceOccurencesOfString:withString:options:range


  • Subject: Re: Re: Correct usage of replaceOccurencesOfString:withString:options:range
  • From: <email@hidden>
  • Date: Fri, 25 Feb 2005 7:06:06 +0000

Thank you again, Robert!  I didn't think of that because I assumed that since the backslash character was inside a string object that it wouldn't interpret it as an escape character.  I know better know.  Thank you again!

James

>
> From: Robert Martin <email@hidden>
> Date: 2005/02/25 Fri AM 06:51:48 GMT
> To: email@hidden
> Subject: Re: Correct usage of replaceOccurencesOfString:withString:options:range
>
> Since it's the escape that's illegal, try escaping the escape - ie:
> make your replacement string: @"\\ ". This will put the 'illegal by
> itself' escape<space> into the string.
>
> Rob
>
> On Feb 25, 2005, at 1:12 AM, email@hidden wrote:
>
> > Could someone please illustrate the correct usage of this method from
> > NSMutableString?  I have a string that represents a path to a file on
> > the filesystem.  If there are any spaces in the path (such as a folder
> > name), I need to escape those spaces with a "\" so I can use them as
> > an argument to an NSTask running a command-line tool.
> >
> > It shows that it returns an unsigned int, so I've tried this:
> >
> > unsigned int i;
> > NSString* str = @"My Documents/Documents/James Stuff/";
> > i = [replaceOccurencesOfString:@" " withString"@"\ " options:nil
> > range:NSMakeRange([0, str length])];
> >
> > But that doesn't work.  It gives me two errors of "unknown escape
> > sequence: '\040'.
> >
> > It shouldn't be that hard to replace all occurences of a space with an
> > backslash and a space, should it?
> >
> > James
> >
> >  _______________________________________________
> > 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
> >
>
>

 _______________________________________________
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

  • Prev by Date: Re: NSString's compare: doesn't work...
  • Next by Date: Re: Notification on network config change
  • Previous by thread: Re: NSString's compare: doesn't work...
  • Next by thread: Re: Correct usage of replaceOccurencesOfString:withString:options:range
  • Index(es):
    • Date
    • Thread