• 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
Better way to replace a character in a string?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Better way to replace a character in a string?


  • Subject: Better way to replace a character in a string?
  • From: Tom Gray <email@hidden>
  • Date: Thu, 01 Aug 2002 00:37:57 -0400

Howdy,

Thanks in advance!

Is there a better way to replace a single character in an NSMutableString
then this:

// Create an NSString from our character.
tempString = [NSString stringWithCString:&theCharacter length:1];

// Get the desired location for the character replacement.
range.location = desiredOffset;
range.length = 1;

// Replace the character in the terminal string with the new character.
[myMutableString replaceCharactersInRange:range withString:tempString];

Oh, by the way, for those of you who have been watching. I finally figured
out attributed strings. Duh. Sometimes I am really slow on the up take.

--

Tom Gray
email@hidden
or
email@hidden
_______________________________________________
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.

  • Follow-Ups:
    • Re: Better way to replace a character in a string?
      • From: Ondra Cada <email@hidden>
    • Re: Better way to replace a character in a string?
      • From: Philippe Martin <email@hidden>
  • Prev by Date: Fwd: -setNeedsDisplay/-display don't work with NSTableView column titles !
  • Next by Date: teaching a game to "speak" different languages
  • Previous by thread: Fwd: -setNeedsDisplay/-display don't work with NSTableView column titles !
  • Next by thread: Re: Better way to replace a character in a string?
  • Index(es):
    • Date
    • Thread