On 02 Apr 2015, at 13:54, Charles Jenkins <cejw...@gmail.com 
<mailto:cejw...@gmail.com>> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to