Re: attributedStringByTrimmingCharactersInSet: method?
Re: attributedStringByTrimmingCharactersInSet: method?
- Subject: Re: attributedStringByTrimmingCharactersInSet: method?
- From: "Adam R. Maxwell" <email@hidden>
- Date: Sun, 23 Jul 2006 07:08:37 -0700
On Jul 23, 2006, at 03:44, Keith Blount wrote:
Hi,
I want to trim the whitespace from either end of an
attributed string. I had assumed that there would be
an attributed variant of NSString's
-stringByTrimmingCharactersInSet: method, which would
make this job very easy, but there doesn't seem to be
one. Do I need to go and write my own method to do
this, or am I missing something really obvious?
For stuff like this you generally need to operate on the characters.
I think the easiest way would be to create a mutable copy of your
attributed string and then modify its mutableString directly:
CFStringTrimWhitespace((CFMutableStringRef)[mutableAttributedString
mutableString])
NSMutableString doesn't have an equivalent of CFStringTrimWhitespace,
and you don't want to create a new instance with
stringByTrimmingCharactersInSet:.
hth,
Adam
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden