func createIBANNumber String var IBAN self removedSpaces var chars Arr

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
func createIBANNumber() -> String {
var IBAN = self.removedSpaces
var chars = Array(IBAN)
var charsIBAN = String()
chars.removeSubrange(0...3)
chars.append(Character(IBAN[0]))
chars.append(Character(IBAN[1]))
chars.append(contentsOf: "0")
chars.append(contentsOf: "0")
let stringNumber = ["A": "10", "B": "11", "C": "12", "D": "13", "E": "14", "F": "15", "G": "16", "H": "17", "I": "18", "J": "19", "K": "20", "L": "21", "M": "22", "N": "23", "O": "24", "P": "25", "Q": "26", "R": "27", "S": "28", "T": "29", "U": "30", "V": "31", "W": "32", "X": "33", "Y": "34", "Z": "35"]
for i in 0..<chars.count {
if let value = stringNumber[String(chars[i])] {
charsIBAN += value
} else {
charsIBAN += String(chars[i])
}
}
let iban = BigInt(charsIBAN)
let a = iban! / 97
let b = a * 97
let k = iban! - b
let c = 98 - k
if c < 10 {
IBAN = "0\(c)"
} else {
IBAN = "\(c)"
}
return IBAN
}