Handling strings in Swift is STRANGE!

Some hints and links


1) Handling substrings

See this excellent website about using the strange new string.substringwithrange( range: Range<String.Index>) and the String.substringFromIndex( index: String.index)

let myString = "[ABCDEFGHI]"
let startIndex = advance(myString.startIndex, 1)
let endIndex = advance(myString.endIndex, -1)
//start- and endIndexes are now String.Indexes
//lets build a range
let range = startIndex..<endIndex
//Finally get the substrings
let myNewString = myString.substringWithRange( range )
let mySubString = myString.substringFromIndex(startIndex)