• 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: String subtraction
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: String subtraction


  • Subject: Re: String subtraction
  • From: Greg Weston <email@hidden>
  • Date: Tue, 25 Mar 2003 07:48:49 -0500

On Tuesday, March 25, 2003, at 01:00 AM, Andrew Merenbach <email@hidden> wrote:

What is the best way to subtract characters in a given set from a
string? For example, I might wish in one instance to remove the
letters "e," "o," and "h" from "hello, world," yielding "ll, wrld."


Others have already suggested alternative implementations, but as for why your attempted reimplementation of the JavaScript fails...

NSString *c1 = [s1 substringWithRange:NSMakeRange(i-1,i)];

The second argument to NSMakeRange is not the end of the range; it's the length. If I'm reading the intent correctly, you always want that to be 1.

G
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: socket sample in cocoa
  • Next by Date: 3 obj-c/cocoa beginner q's
  • Previous by thread: Re: String subtraction
  • Next by thread: AppleSkript & cocoa App
  • Index(es):
    • Date
    • Thread