I am a beginner of Swift for iOS development, and want to find an elegant way to loop through an array from the second element.
If it is in Objective-C, I think I ca
you can also use custom subscript to make sure you avoid crashing
extension Array {
subscript (gurd index: Index) -> Array.Element? {
return (index < self.count && index >= 0) ? self[index] : nil
}
}
use example:
let myarray = ["a","b","c","d","e","f","g","h"]
for i in -15...myarray.count+20{
print(myarray[gurd: i])
}