• 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: Examples of replacement of chars in NSMutableStrings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Examples of replacement of chars in NSMutableStrings


  • Subject: Re: Examples of replacement of chars in NSMutableStrings
  • From: Chris Ridd <email@hidden>
  • Date: Thu, 04 Jul 2002 17:51:46 +0100

On 4/7/02 5:07 pm, Nikita Zhuk <email@hidden> wrote:

> Hi all,
>
> Is there some examples available (or could someone write one), which
> would clearly show, how simple string replacement works in
> Objective-C ? For example, I have NSMutableString, which contains a
> string "This is cool", and I would like to replace the substring "is
> " to "is very ".
>
> Greets,
> Nikita Zhuk

How's this?

NSMutableString *original = [[NSMutableString alloc] initWithString:
@"This is cool"];
NSRange r;
r = [original rangeOfString: @"is"];
if (r.location != NSNotFound) {
[original replaceCharactersInRange: r
withString: @"is very"];
}

Cheers,

Chris
_______________________________________________
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.

References: 
 >Examples of replacement of chars in NSMutableStrings (From: Nikita Zhuk <email@hidden>)

  • Prev by Date: Re: Cocoa stripping resource forks: does Jaguar fix?
  • Next by Date: hostWithAddress trouble
  • Previous by thread: Examples of replacement of chars in NSMutableStrings
  • Next by thread: Cocoa-Java instance variables
  • Index(es):
    • Date
    • Thread