Re: Swift: How to determine if a Character represents whitespace?
Re: Swift: How to determine if a Character represents whitespace?
- Subject: Re: Swift: How to determine if a Character represents whitespace?
- From: Uli Kusterer <email@hidden>
- Date: Thu, 02 Apr 2015 14:23:24 +0200
On 02 Apr 2015, at 13:54, Charles Jenkins <email@hidden <mailto:email@hidden>> wrote:
> What would be nice is a way to count leading and trailing characters in place while the thing is still an NSAttributedString--without using NSAttributedString.string to convert to a Swift string in the first place. If there were no conversion to the unicode-compliant and amazingly difficult-to-do-anything-with-it Swift string, I’d be more confident that the shrunken range I calculate would be apples to apples.
Does Swift have an equivalent to rangeOfCharacterFromSet:options: or would that require converting it to NSString?
Because you could just generate the inverse NSCharacterSet to the whitespace character set, and then look for the first (NSAnchoredSearch) and last (NSAnchoredSearch | NSBackwardsSearch) non-whitespace character, and then extract only the range between those two offsets.
Wildly guessing,
-- Uli Kusterer
http://stacksmith <http://stacksmith/>.org
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden