 
 extension String {
     subscript (i: Int) -> Character {
-        return self[advance(self.startIndex, i)]
+        return self[self.startIndex.advancedBy(i)]
     }
     
     subscript (i: Int) -> String {

    }
    
    func formattedExpiration(divider: String) -> String {
        var idx = advance(cardExpiration.startIndex, 2)
        var month = cardExpiration.substringToIndex(idx)
        var year  = cardExpiration.substringFromIndex(idx)
        return "\(month)\(divider)\(year)"
    }
}
    }
    
    subscript (r: Range<Int>) -> String {
        return substringWithRange(Range(start: self.startIndex.advancedBy(r.startIndex), end: self.startIndex.advancedBy(r.endIndex)))
    }
}

struct TKSwipeData {
    var swipeData: String
    
    var cardHolder: String {
        get {
            let cardHolder = swipeData.componentsSeparatedByString("^")[1]
            if cardHolder.containsString("/") {
                let cardHolderParts = cardHolder.componentsSeparatedByString("/")
                if cardHolderParts.count > 1 {
                    return "\(cardHolderParts[1]) \(cardHolderParts[0])"
                }
                else {
                    return cardHolderParts[1]
                }
            }
            else {
                return cardHolder
            }
        }
    }
    
    var cardNumber: String {
        get {
            let charIndex = swipeData.rangeOfString("^")!
            let sIndex = swipeData.startIndex.advancedBy(2)
            let eIndex = charIndex.endIndex.advancedBy(-1)
            return swipeData.substringWithRange(sIndex..<eIndex)
        }
    }
    
    var cardLastFour: String {
        get {
            let eIndex = cardNumber.endIndex.advancedBy(-4)
            return cardNumber.substringFromIndex(eIndex)
        }
    }
    
    var cardExpiration: String {
        get {
            let expParts = swipeData.componentsSeparatedByString("^")[2]
            return "\(expParts[2..<4])\(expParts[0..<2])"
        }
    }
