This actually is possible if you're willing to make a wrapper around your tuple. That being said, this is terrible, don't ever do this. The suggestions made in the other answers are practically a lot better, but for education purposes, here's my example.
struct TupleWrapper {
let tuple: (String, Int, String, String, String, String, String, Bool)
let count: Int
private let mirrors: [MirrorType]
subscript (index: Int) -> Any {
return mirrors[index].value
}
init(tuple: (String, Int, String, String, String, String, String, Bool)) {
self.tuple = tuple
var mirrors = [MirrorType]()
let reflected = reflect(tuple)
for i in 0..<reflected.count {
mirrors.append(reflected[i].1)
}
self.mirrors = mirrors
self.count = mirrors.count
}
}
let wrapper = TupleWrapper(tuple: ("1", 2, "3", "4", "5", "6", "7", false))
wrapper[0] // "1"
wrapper[wrapper.count - 1] // false
The code above uses Swift's reflection APIs to get the logical children of your tuple object and add their mirrors to an array on which we can subscript for each mirror's value. This is fairly straight forward, but as you'd expect, since we're working with tuples here, this can't really be made dynamic in any way. The wrapper has to be made for a specific tuple type.
For some related reading, see NSHipster's recent MirrorType article.