How to concatenate an integer variable with string variables



I am using Swift 5.1.3. I can’t get a simple Int variable to concatenate with String variables.

Any help will be appreciated. I want to include a percentage from two numbers with a string of Strings. Belowis my code:


I am getting an error on line 12: Binary operator ‘+’ cannot be applied to operands of type ‘String’ and ‘Int’

referencing “groupPercent”


func getPercent(){
                let groupPercent: Double = Double(qmSum) / Double(qaSum) * 100
                 print ("Percent is (groupPercent)")
                let firstPart = (groupNameItem) + (" ")
                let secondPart = ("Group Score") + (" ")
                let newLine = (firstPart + secondPart + groupPercent)
                studentsText?.string = studentsText!.string + newLine + "n"



Powered by WPeMatico

You may also like...

Comments are closed.