How to convert String.Index to UInt?
How to convert String.Index to UInt?
- Subject: How to convert String.Index to UInt?
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Sat, 16 Aug 2014 15:30:42 +0700
import Cocoa
let s = "hallo\there"
let aas = NSMutableAttributedString( string: s, attributes: nil )
let rangeOfTab = s.rangeOfString( "\t" )
if rangeOfTab != nil
{
let colour = NSColor.grayColor()
let locationOfTab = rangeOfTab!.startIndex
let aRange = NSRange( location: 0, length: locationOfTab ) <-- error: 'String.Index' is not convertible to 'Int'
aas.addAttribute( NSForegroundColorAttributeName, value: colour, range: aRange )
}
How can I convert a String.Index into an UInt (or Int or whatever)?
Gerriet.
_______________________________________________
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