Re: Better way to replace a character in a string?
Re: Better way to replace a character in a string?
- Subject: Re: Better way to replace a character in a string?
- From: Philippe Martin <email@hidden>
- Date: Thu, 1 Aug 2002 18:39:40 +0200
At 00:37 -0400 01/08/02, Tom Gray wrote:
>
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];
I'd do something like this:
NSArray *temp = [ myString componentsSeparatedByString:searchString ];
return [ temp componentsJoinedByString:replaceString ];
Philippe
--
______________________________________________________________________
Philippe MARTIN (a.k.a. Flip)
mailto:email@hidden
http://www.MacrobyteResources.com http://www.Free-Conversant.com
_______________________________________________
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.