Unified Contacts

29 August, 2015

advance(startIndex, n) is change to Index.advancedBy(n)

In Xcode 7 Beta 6 global function advance(startIndex, n) is no longer available. You must use Index.advancedBy(n) to get the same result. advance(startIndex, n) is very useful in substringing. Since you cannot pass an Int to the Index type in substring function.

Prior to Xcode 7 Beta 6
var str = "abc"
firstChar = str.substringToIndex(advance(str.startIndex, 1))   // a

Xcode 7 Beta6
var str = "abc"
firstChar = str.substringToIndex(str.startIndex.advancedBy(1))  // a