Re: Examples of replacement of chars in NSMutableStrings
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.