I am new to swift development. Actually it is a simple problem but I cannot figure it out. I have a String variable "name1" where I want to determine the position in the alphabet for each character and sum these positions. Therefore I loop through the string and use indexOf() for every character
let name1="myname"
let sumPositions=0
for index in 0...name1.characters.count-1{
sumPositions+="ABCDEFGHIJKLMNOPQRSTUVWXYZ".characters.indexOf(name1.startIndex+index);
}
I get the error "Binary operator "+" cannot be applied to operands of type 'index' aka 'String.characterView.index' and 'Int'. This means I have to cast 'index' to 'Int' but I did not find a solution for this.