• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Swift: How to determine if a Character represents whitespace?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Swift: How to determine if a Character represents whitespace? (From: Charles Jenkins <email@hidden>)
 >Re: Swift: How to determine if a Character represents whitespace? (From: Charles Srstka <email@hidden>)
 >Re: Swift: How to determine if a Character represents whitespace? (From: Charles Jenkins <email@hidden>)
 >Re: Swift: How to determine if a Character represents whitespace? (From: Quincey Morris <email@hidden>)
 >Re: Swift: How to determine if a Character represents whitespace? (From: Charles Jenkins <email@hidden>)

  • Prev by Date: Re: Swift: How to determine if a Character represents whitespace?
  • Next by Date: Re: Swift: How to determine if a Character represents whitespace?
  • Previous by thread: Re: Swift: How to determine if a Character represents whitespace?
  • Next by thread: Re: Swift: How to determine if a Character represents whitespace?
  • Index(es):
    • Date
    • Thread