On 2015-12-06 14:45, Michel Fortin wrote:
That only works if the actual underlying representation is UTF8 (or
other single-byte encoding). String abstracts that away from you. But
you can do this if you want to work with bytes:
let utf8View = str.utf8
utf8View[utf8View.startIndex.advancedBy(2) ..<
utf8View.endIndex.advancedBy(-1)]
or:
let arrayOfBytes = Array(str.utf8)
arrayOfBytes[2 ..< arrayOfBytes.count-1]
All these just show that it's still too complicated ;)
container.indexOf(predicate)
container.indexOf { (element) in element == "p" }
container.indexOf { $0 == "p" }
container[index]
That's what I ended up doing.
--
/Jacob Carlborg