Re: Changing Case
Re: Changing Case
- Subject: Re: Changing Case
- From: Alastair Houghton <email@hidden>
- Date: Thu, 18 Mar 2004 17:48:52 +0000
On 18 Mar 2004, at 17:36, Stephane Sudre wrote:
>
On Thursday, March 18, 2004, at 03:40 PM, Alastair Houghton wrote:
>
>
> On 18 Mar 2004, at 13:48, Mathew Peterson wrote:
>
>
>
>> Is there any neat Cocoa way of changing the case of a single
>
>> character
>
>> or string? I am just looking around in the NSText world for the first
>
>> time and I am probably missing something rather simple.
>
>
>
> What's wrong with doing e.g.
>
>
>
> NSMutableString *myString = [NSMutableString
>
> stringWithUTF8String:"hello"];
>
> NSRange rangeOfCharacter = NSMakeRange(0,1);
>
>
>
> [myString
>
> replaceCharactersInRange:rangeOfCharacter
>
> withString:[[myString substringWithRange:rangeOfCharacter]
>
> uppercaseString]];
>
>
>
> I suppose you might argue that this kind of thing is overkill
>
>
It's potentially a monster kill.
Not at all. If you want to change the case of a single character, you
need to do (roughly) what I wrote. I was giving Matthew the benefit of
the doubt and assuming that he was having trouble changing the case of
a single character in a string, rather than a whole string, since the
latter is easy to find in the documentation. If it was a whole string
that he wanted, then, of course, as you (and others) have said, it's
only necessary to use a single -uppercaseString message.
Kind regards,
Alastair.
--
Alastair Houghton
http://www.alastairs-place.net
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.